From nobody Mon Apr 29 13:23:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585235736; cv=none; d=zohomail.com; s=zohoarc; b=Zf6dSU13hc6dGUzU5ydXQ6MgP89t4ntb71pNIC97n01mHGppYkGqpWtLGE3uXUADcfIpJqGH17R+cuMK/QbI/LZWHTxqdqmv0PcOjDXLt7PxVjCOdJz1C67cde+NKni2QyKDkP1LWCFPWR8NU0Qe0hkhw+BwawtJeQdDwG6Szyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585235736; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Toqcmt7rh8n/Zf576pFJwL0zzsPV1Pdmn5sE66sLFvY=; b=LuG8Lm4BqDVDjkbkEjWq33TDW5ywtGL1TI+STK/ES7ijeuimjj6cbWbf5Op1M2ezXOusH8n1rsqfL48kBIjF8+3L0w4D9gcHG8o/kV4QrKZhSyryPPJk3q+YdtX9EY0NZVn0XwS+lznNI5BzF7O8muMipDcWpkp7b+P7XFLi+58= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1585235736954890.0971319123436; Thu, 26 Mar 2020 08:15:36 -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-125-DfdUnQMGMLuwQnjJLvzQnA-1; Thu, 26 Mar 2020 11:15:33 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1567192D785; Thu, 26 Mar 2020 15:15:26 +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 74CAF10002A5; Thu, 26 Mar 2020 15:15:26 +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 B535D8A03C; Thu, 26 Mar 2020 15:15:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QFFKqx028988 for ; Thu, 26 Mar 2020 11:15:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id DC681386; Thu, 26 Mar 2020 15:15:20 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5992119C70 for ; Thu, 26 Mar 2020 15:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585235735; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Toqcmt7rh8n/Zf576pFJwL0zzsPV1Pdmn5sE66sLFvY=; b=Gbq8cCfpxoBCSCvEl2Ae7bu1flprDNVhJqq1++Ka1o9NdFOn6ISloflgK/LCUsCEbcyKw4 zUrlZkLfghIwr5VCiK3u/kDmQI9iRxR+eCcfk8vyGl04JMJMou0aC1lr4yW4mcIxe5BQrr WsdB/pLuxXZqlNjbYa9qLB/ZrHQZXBQ= X-MC-Unique: DfdUnQMGMLuwQnjJLvzQnA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 01/11] tests: Fix virQEMUDriverConfigNew() calling with respect to @root Date: Thu, 26 Mar 2020 16:15:05 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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" The virQEMUDriverConfigNew() accepts path to root directory for embed mode as an argument. If the argument is not NULL it uses the passed value as prefix for some internal paths (e.g. cfg->libDir). If it is NULL though, it looks if the other argument, @privileged is true or false and generates internal paths accordingly. But when calling the function from the test suite, instead of passing NULL for @root, an empty string is passed. Fortunately, this doesn't create a problem because in both problematic cases the generated paths are "fixed" to point somewhere into build dir or the code which is tested doesn't access them. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/domaincapstest.c | 2 +- tests/testutilsqemu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index fb803eaa47..c3a9f4ef91 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -369,7 +369,7 @@ mymain(void) #endif =20 #if WITH_QEMU - virQEMUDriverConfigPtr cfg =3D virQEMUDriverConfigNew(false, ""); + virQEMUDriverConfigPtr cfg =3D virQEMUDriverConfigNew(false, NULL); =20 if (!cfg) return EXIT_FAILURE; diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index f3b4e2b3b2..cb68ac0488 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -390,7 +390,7 @@ int qemuTestDriverInit(virQEMUDriver *driver) return -1; =20 driver->hostarch =3D virArchFromHost(); - driver->config =3D virQEMUDriverConfigNew(false, ""); + driver->config =3D virQEMUDriverConfigNew(false, NULL); if (!driver->config) goto error; =20 --=20 2.24.1 From nobody Mon Apr 29 13:23:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585235834; cv=none; d=zohomail.com; s=zohoarc; b=Y9b0vaXbHR1JGTWAD5Snlv+gB2q4UnVRQoqdLzauskdMj6228d0ajLhs8zgWNFRq6vDezefffWgo2CXFbQZJT76JszgQfuRsgIzvYrgkD8l5oSRR9Ut+0/uz8qVcsrxjb05mgJkdPMEF6ypTCIkpIqFQbbN7GQqFO0xt0E4gHvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585235834; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XBYQWc/9/SWJT6jPPDlxjGfIc49tF1DD44k+Rn8+5c8=; b=eBrCK7q8OgptExb1cWrhsyvQ3nAjM1rwOZySyQ/2u61wDGo/Zfhb0+CAXStrXVXVwg8QDM2HvyHRwGsIjbNO3+PjC8nINMkCNZTxx+6epnmFQ/rzI6c3mVbwSzwqQ5/eHTM/n4jXBrXCp2H2wJo/AEx+QKBmH0fh16j9YnZQm1w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1585235834965929.0226285673435; Thu, 26 Mar 2020 08:17:14 -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-97-jZZAt01gOVql5YJkVXB9OQ-1; Thu, 26 Mar 2020 11:15:44 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36CE1192D786; Thu, 26 Mar 2020 15:15: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 0972C10002A5; Thu, 26 Mar 2020 15:15: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 7951F18089CF; Thu, 26 Mar 2020 15:15:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QFFL0M028998 for ; Thu, 26 Mar 2020 11:15:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id ECB54395; Thu, 26 Mar 2020 15:15:21 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D90B19C70 for ; Thu, 26 Mar 2020 15:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585235831; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XBYQWc/9/SWJT6jPPDlxjGfIc49tF1DD44k+Rn8+5c8=; b=LqvdMYBZoFrsAm9K5JdVYegmIAkisRzhr44FNYanryBmvkHe0lt/kAncQn1FhDjXdrGYXL D+mGon4qVJMlKfHCmJTwZoJla+ZTcOID3q9YXNeXfw6HHWTXXrQ0XNa0vbFRjmqmFI2LVE vv+jOo/N/KjPdVmKzHW5aMMmISDO//E= X-MC-Unique: jZZAt01gOVql5YJkVXB9OQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 02/11] qemu: Drop two layers of nesting of memoryBackingDir Date: Thu, 26 Mar 2020 16:15:06 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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" Initially introduced in v3.10.0-rc1~172. When generating a path for memory-backend-file or -mem-path, qemu driver will use the following pattern: $memoryBackingDir/libvirt/qemu/$id-$shortName where $memoryBackingDir defaults to /var/lib/libvirt/qemu/ram but can be overridden in qemu.conf. Anyway, the "/libvirt/qemu/" part looks redundant, because it's already contained in the default, or creates unnecessary nesting if overridden in qemu.conf. Signed-off-by: Michal Privoznik --- src/qemu/qemu_conf.c | 12 +----------- src/qemu/qemu_conf.h | 2 -- src/qemu/qemu_driver.c | 12 +----------- tests/qemuxml2argvdata/cpu-numa-memshared.args | 8 ++++---- .../qemuxml2argvdata/fd-memory-no-numa-topology.args | 2 +- tests/qemuxml2argvdata/fd-memory-numa-topology.args | 4 ++-- tests/qemuxml2argvdata/fd-memory-numa-topology2.args | 8 ++++---- tests/qemuxml2argvdata/fd-memory-numa-topology3.args | 12 ++++++------ tests/qemuxml2argvdata/hugepages-memaccess2.args | 12 ++++++------ tests/qemuxml2argvdata/pages-dimm-discard.args | 4 ++-- .../vhost-user-fs-fd-memory.x86_64-latest.args | 2 +- 11 files changed, 28 insertions(+), 50 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 15837cece4..9786e19f8f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1951,27 +1951,17 @@ qemuGetDomainHupageMemPath(const virDomainDef *def, } =20 =20 -void -qemuGetMemoryBackingBasePath(virQEMUDriverConfigPtr cfg, - char **path) -{ - *path =3D g_strdup_printf("%s/libvirt/qemu", cfg->memoryBackingDir); -} - - int qemuGetMemoryBackingDomainPath(const virDomainDef *def, virQEMUDriverConfigPtr cfg, char **path) { g_autofree char *shortName =3D NULL; - g_autofree char *base =3D NULL; =20 if (!(shortName =3D virDomainDefGetShortName(def))) return -1; =20 - qemuGetMemoryBackingBasePath(cfg, &base); - *path =3D g_strdup_printf("%s/%s", base, shortName); + *path =3D g_strdup_printf("%s/%s", cfg->memoryBackingDir, shortName); =20 return 0; } diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 14f9b9e81e..c8d3e439e0 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -398,8 +398,6 @@ int qemuGetDomainHupageMemPath(const virDomainDef *def, unsigned long long pagesize, char **memPath); =20 -void qemuGetMemoryBackingBasePath(virQEMUDriverConfigPtr cfg, - char **path); int qemuGetMemoryBackingDomainPath(const virDomainDef *def, virQEMUDriverConfigPtr cfg, char **path); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 570dc059e9..5cbf2f2478 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -640,7 +640,6 @@ qemuStateInitialize(bool privileged, virQEMUDriverConfigPtr cfg; uid_t run_uid =3D -1; gid_t run_gid =3D -1; - g_autofree char *memoryBackingPath =3D NULL; bool autostart =3D true; size_t i; const char *defsecmodel =3D NULL; @@ -935,17 +934,8 @@ qemuStateInitialize(bool privileged, goto error; } =20 - qemuGetMemoryBackingBasePath(cfg, &memoryBackingPath); - - if (virFileMakePath(memoryBackingPath) < 0) { - virReportSystemError(errno, - _("unable to create memory backing path %s"), - memoryBackingPath); - goto error; - } - if (privileged && - virFileUpdatePerm(memoryBackingPath, + virFileUpdatePerm(cfg->memoryBackingDir, 0, S_IXGRP | S_IXOTH) < 0) goto error; =20 diff --git a/tests/qemuxml2argvdata/cpu-numa-memshared.args b/tests/qemuxml= 2argvdata/cpu-numa-memshared.args index 752eed8d13..8e214189db 100644 --- a/tests/qemuxml2argvdata/cpu-numa-memshared.args +++ b/tests/qemuxml2argvdata/cpu-numa-memshared.args @@ -15,12 +15,12 @@ QEMU_AUDIO_DRV=3Dnone \ -realtime mlock=3Doff \ -smp 16,sockets=3D2,cores=3D4,threads=3D2 \ -object memory-backend-file,id=3Dram-node0,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node0,\ -share=3Dyes,size=3D112197632 \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node0,share=3Dyes,\ +size=3D112197632 \ -numa node,nodeid=3D0,cpus=3D0-7,memdev=3Dram-node0 \ -object memory-backend-file,id=3Dram-node1,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node1,\ -share=3Dno,size=3D112197632 \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node1,share=3Dno,\ +size=3D112197632 \ -numa node,nodeid=3D1,cpus=3D8-15,memdev=3Dram-node1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -display none \ diff --git a/tests/qemuxml2argvdata/fd-memory-no-numa-topology.args b/tests= /qemuxml2argvdata/fd-memory-no-numa-topology.args index d23c575553..dec35cc10a 100644 --- a/tests/qemuxml2argvdata/fd-memory-no-numa-topology.args +++ b/tests/qemuxml2argvdata/fd-memory-no-numa-topology.args @@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=3Dnone \ -machine pc-i440fx-2.3,accel=3Dkvm,usb=3Doff,dump-guest-core=3Doff \ -m 14336 \ -mem-prealloc \ --mem-path /var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram \ +-mem-path /var/lib/libvirt/qemu/ram/-1-instance-00000092/ram \ -realtime mlock=3Doff \ -smp 8,sockets=3D8,cores=3D1,threads=3D1 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ diff --git a/tests/qemuxml2argvdata/fd-memory-numa-topology.args b/tests/qe= muxml2argvdata/fd-memory-numa-topology.args index 4fbbc8185b..2d3e90ff7a 100644 --- a/tests/qemuxml2argvdata/fd-memory-numa-topology.args +++ b/tests/qemuxml2argvdata/fd-memory-numa-topology.args @@ -16,8 +16,8 @@ QEMU_AUDIO_DRV=3Dnone \ -realtime mlock=3Doff \ -smp 8,sockets=3D1,cores=3D8,threads=3D1 \ -object memory-backend-file,id=3Dram-node0,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram= -node0,\ -share=3Dyes,size=3D15032385536 \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node0,share= =3Dyes,\ +size=3D15032385536 \ -numa node,nodeid=3D0,cpus=3D0-7,memdev=3Dram-node0 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ -display none \ diff --git a/tests/qemuxml2argvdata/fd-memory-numa-topology2.args b/tests/q= emuxml2argvdata/fd-memory-numa-topology2.args index 1eeeaec0ce..6b1695feb1 100644 --- a/tests/qemuxml2argvdata/fd-memory-numa-topology2.args +++ b/tests/qemuxml2argvdata/fd-memory-numa-topology2.args @@ -16,12 +16,12 @@ QEMU_AUDIO_DRV=3Dnone \ -realtime mlock=3Doff \ -smp 20,sockets=3D1,cores=3D8,threads=3D1 \ -object memory-backend-file,id=3Dram-node0,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram= -node0,\ -share=3Dno,size=3D15032385536 \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node0,share= =3Dno,\ +size=3D15032385536 \ -numa node,nodeid=3D0,cpus=3D0-7,memdev=3Dram-node0 \ -object memory-backend-file,id=3Dram-node1,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram= -node1,\ -share=3Dyes,size=3D15032385536 \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node1,share= =3Dyes,\ +size=3D15032385536 \ -numa node,nodeid=3D1,cpus=3D8-15,memdev=3Dram-node1 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ -display none \ diff --git a/tests/qemuxml2argvdata/fd-memory-numa-topology3.args b/tests/q= emuxml2argvdata/fd-memory-numa-topology3.args index d75b67916c..205d14a7db 100644 --- a/tests/qemuxml2argvdata/fd-memory-numa-topology3.args +++ b/tests/qemuxml2argvdata/fd-memory-numa-topology3.args @@ -16,16 +16,16 @@ QEMU_AUDIO_DRV=3Dnone \ -realtime mlock=3Doff \ -smp 32,sockets=3D1,cores=3D24,threads=3D1 \ -object memory-backend-file,id=3Dram-node0,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram= -node0,\ -share=3Dyes,size=3D15032385536 \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node0,share= =3Dyes,\ +size=3D15032385536 \ -numa node,nodeid=3D0,cpus=3D0-1,memdev=3Dram-node0 \ -object memory-backend-file,id=3Dram-node1,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram= -node1,\ -share=3Dyes,size=3D15032385536 \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node1,share= =3Dyes,\ +size=3D15032385536 \ -numa node,nodeid=3D1,cpus=3D2-3,memdev=3Dram-node1 \ -object memory-backend-file,id=3Dram-node2,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-instance-00000092/ram= -node2,\ -share=3Dno,size=3D15032385536 \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node2,share= =3Dno,\ +size=3D15032385536 \ -numa node,nodeid=3D2,cpus=3D4-5,memdev=3Dram-node2 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ -display none \ diff --git a/tests/qemuxml2argvdata/hugepages-memaccess2.args b/tests/qemux= ml2argvdata/hugepages-memaccess2.args index 654baebf9f..c1560e63c3 100644 --- a/tests/qemuxml2argvdata/hugepages-memaccess2.args +++ b/tests/qemuxml2argvdata/hugepages-memaccess2.args @@ -15,20 +15,20 @@ QEMU_AUDIO_DRV=3Dnone \ -realtime mlock=3Doff \ -smp 4,sockets=3D4,cores=3D1,threads=3D1 \ -object memory-backend-file,id=3Dram-node0,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node0,\ -share=3Dno,size=3D1073741824,host-nodes=3D0-3,policy=3Dbind \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node0,share=3Dno,\ +size=3D1073741824,host-nodes=3D0-3,policy=3Dbind \ -numa node,nodeid=3D0,cpus=3D0,memdev=3Dram-node0 \ -object memory-backend-file,id=3Dram-node1,prealloc=3Dyes,\ mem-path=3D/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=3Dyes,size=3D= 1073741824,\ host-nodes=3D0-3,policy=3Dbind \ -numa node,nodeid=3D1,cpus=3D1,memdev=3Dram-node1 \ -object memory-backend-file,id=3Dram-node2,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node2,\ -share=3Dno,size=3D1073741824,host-nodes=3D0-3,policy=3Dbind \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node2,share=3Dno,\ +size=3D1073741824,host-nodes=3D0-3,policy=3Dbind \ -numa node,nodeid=3D2,cpus=3D2,memdev=3Dram-node2 \ -object memory-backend-file,id=3Dram-node3,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node3,\ -share=3Dno,size=3D1073741824,host-nodes=3D3,policy=3Dbind \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node3,share=3Dno,\ +size=3D1073741824,host-nodes=3D3,policy=3Dbind \ -numa node,nodeid=3D3,cpus=3D3,memdev=3Dram-node3 \ -object memory-backend-file,id=3Dmemdimm0,prealloc=3Dyes,\ mem-path=3D/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=3Dyes,size=3D= 536870912,\ diff --git a/tests/qemuxml2argvdata/pages-dimm-discard.args b/tests/qemuxml= 2argvdata/pages-dimm-discard.args index fefa205597..96e9ffdec3 100644 --- a/tests/qemuxml2argvdata/pages-dimm-discard.args +++ b/tests/qemuxml2argvdata/pages-dimm-discard.args @@ -20,8 +20,8 @@ mem-path=3D/dev/hugepages1G/libvirt/qemu/-1-fedora,size= =3D1073741824,\ host-nodes=3D1-3,policy=3Dbind \ -device pc-dimm,node=3D0,memdev=3Dmemdimm0,id=3Ddimm0,slot=3D0 \ -object memory-backend-file,id=3Dmemdimm1,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-fedora/dimm1,\ -discard-data=3Dyes,share=3Dno,size=3D536870912 \ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-fedora/dimm1,discard-data=3Dyes,sh= are=3Dno,\ +size=3D536870912 \ -device pc-dimm,node=3D0,memdev=3Dmemdimm1,id=3Ddimm1,slot=3D1 \ -uuid 63840878-0deb-4095-97e6-fc444d9bc9fa \ -display none \ diff --git a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.a= rgs b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args index a7df45a7f0..dd5f68abc5 100644 --- a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args +++ b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args @@ -18,7 +18,7 @@ file=3D/tmp/lib/domain--1-guest/master-key.aes \ -overcommit mem-lock=3Doff \ -smp 2,sockets=3D2,cores=3D1,threads=3D1 \ -object memory-backend-file,id=3Dram-node0,\ -mem-path=3D/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-guest/ram-node0,share= =3Dyes,\ +mem-path=3D/var/lib/libvirt/qemu/ram/-1-guest/ram-node0,share=3Dyes,\ size=3D15032385536 \ -numa node,nodeid=3D0,cpus=3D0-1,memdev=3Dram-node0 \ -uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ --=20 2.24.1 From nobody Mon Apr 29 13:23:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585235839; cv=none; d=zohomail.com; s=zohoarc; b=b50WyRQZ5mUdpj0c5XMq9xqDMQ7++nhVP3BL0pF0r192GjRUAg4uRDm8gdydwIdlUxvtPBy8VSXKeuhbsYscJqdXFxnpu6g14ckCewFFpSx+cMdEqfTufSHv1OEUIY0m8J4Zo6jzirhTikHVt3kmmMMo0suWUFTqt4Ct8g/JRS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585235839; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iK/vLjzcjtLR8CyWP/A7UT8mnd65lyuCSYS7mGgtSOc=; b=My5p8seAUNurFZUBfnOGTJaEPWLywr5Ry+cpjsKQu3xYLAnpWCA6VUzhIQXsrbaNFmCDimRdc+4XfyqK0jUyc6Behz9SZdBR9YC3JjIEQMKdDbvB7mK9AT9o41MCIYDwWS67MdDka9fExSOM5lqw2zjTQp8kUmydwTQrpn6FAcU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1585235839639654.8607202717156; Thu, 26 Mar 2020 08:17:19 -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-473-4qkncME6O9C1gMc5-7b7ZQ-1; Thu, 26 Mar 2020 11:16:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 708B5107ACCA; Thu, 26 Mar 2020 15:16:23 +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 3E9B160BF3; Thu, 26 Mar 2020 15:16: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 E940B18089D7; Thu, 26 Mar 2020 15:16:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QFFMIE029003 for ; Thu, 26 Mar 2020 11:15:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id CE244395; Thu, 26 Mar 2020 15:15:22 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C49F19C70 for ; Thu, 26 Mar 2020 15:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585235838; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=iK/vLjzcjtLR8CyWP/A7UT8mnd65lyuCSYS7mGgtSOc=; b=gO0KkFxEVpIazQ7/C7ID6WRenFelWwFEKrojhZddYE/F7fH2aKnMeeNdSDF06hGaQ/cYbF Yt+DBVUy2ZEALHRwHy0pvEz5QvprTJkAIKDiSjy0YphfetdC6uxRHWTWAHrP5qjLszoBnA 70FfMzEdEKJGqYUubC0KImEH0Llle8c= X-MC-Unique: 4qkncME6O9C1gMc5-7b7ZQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 03/11] conf: Move virDomainGenerateMachineName to hypervisor/ Date: Thu, 26 Mar 2020 16:15:07 +0100 Message-Id: <5b4fcbcabc1290ef0a7dc0718a13e977ef99aa0b.1585234828.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" The virDomainGenerateMachineName() function doesn't belong in src/conf/ really, because it has nothing to do with domain XML parsing. It landed there because of lack of better place in the past. But now that we have src/hypervisor/ the function should live there. At the same time, the function name is changed to match new location. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 72 --------------------------------- src/conf/domain_conf.h | 7 ---- src/hypervisor/domain_driver.c | 74 ++++++++++++++++++++++++++++++++++ src/hypervisor/domain_driver.h | 7 ++++ src/libvirt_private.syms | 2 +- src/lxc/lxc_domain.c | 3 +- src/qemu/qemu_domain.c | 7 ++-- tests/virsystemdtest.c | 5 ++- 8 files changed, 91 insertions(+), 86 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 27bc5a797b..239455ef58 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -62,7 +62,6 @@ #include "virdomainsnapshotobjlist.h" #include "virdomaincheckpointobjlist.h" #include "virutil.h" -#include "vircrypto.h" =20 #define VIR_FROM_THIS VIR_FROM_DOMAIN =20 @@ -31032,77 +31031,6 @@ virDomainDiskSetBlockIOTune(virDomainDiskDefPtr di= sk, return 0; } =20 -#define HOSTNAME_CHARS \ - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-" - -static void -virDomainMachineNameAppendValid(virBufferPtr buf, - const char *name) -{ - bool skip =3D true; - - for (; *name; name++) { - if (strlen(virBufferCurrentContent(buf)) >=3D 64) - break; - - if (*name =3D=3D '.' || *name =3D=3D '-') { - if (!skip) - virBufferAddChar(buf, *name); - skip =3D true; - continue; - } - - skip =3D false; - - if (!strchr(HOSTNAME_CHARS, *name)) - continue; - - virBufferAddChar(buf, *name); - } - - /* trailing dashes or dots are not allowed */ - virBufferTrimChars(buf, "-."); -} - -#undef HOSTNAME_CHARS - -char * -virDomainGenerateMachineName(const char *drivername, - const char *root, - int id, - const char *name, - bool privileged) -{ - virBuffer buf =3D VIR_BUFFER_INITIALIZER; - - virBufferAsprintf(&buf, "%s-", drivername); - - if (root) { - g_autofree char *hash =3D NULL; - - /* When two embed drivers start two domains with the same @name an= d @id - * we would generate a non-unique name. Include parts of hashed @r= oot - * which guarantees uniqueness. The first 8 characters of SHA256 o= ught - * to be enough for anybody. */ - if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, root, &hash) < 0) - return NULL; - - virBufferAsprintf(&buf, "embed-%.8s-", hash); - } else if (!privileged) { - g_autofree char *username =3D NULL; - if (!(username =3D virGetUserName(geteuid()))) { - virBufferFreeAndReset(&buf); - return NULL; - } - virBufferAsprintf(&buf, "%s-", username); - } - - virBufferAsprintf(&buf, "%d-", id); - virDomainMachineNameAppendValid(&buf, name); - - return virBufferContentAndReset(&buf); -} - =20 /** * virDomainNetTypeSharesHostView: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 33875d942f..575290a6ac 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3649,13 +3649,6 @@ virDomainGetBlkioParametersAssignFromDef(virDomainDe= fPtr def, int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk, virDomainBlockIoTuneInfo *info); =20 -char * -virDomainGenerateMachineName(const char *drivername, - const char *root, - int id, - const char *name, - bool privileged); - bool virDomainNetTypeSharesHostView(const virDomainNetDef *net); =20 diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index fc5b6eeefe..7bf0fb3f98 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -23,10 +23,84 @@ #include "domain_driver.h" #include "viralloc.h" #include "virstring.h" +#include "vircrypto.h" +#include "virutil.h" =20 #define VIR_FROM_THIS VIR_FROM_DOMAIN =20 =20 +#define HOSTNAME_CHARS \ + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-" + +static void +virDomainMachineNameAppendValid(virBufferPtr buf, + const char *name) +{ + bool skip =3D true; + + for (; *name; name++) { + if (strlen(virBufferCurrentContent(buf)) >=3D 64) + break; + + if (*name =3D=3D '.' || *name =3D=3D '-') { + if (!skip) + virBufferAddChar(buf, *name); + skip =3D true; + continue; + } + + skip =3D false; + + if (!strchr(HOSTNAME_CHARS, *name)) + continue; + + virBufferAddChar(buf, *name); + } + + /* trailing dashes or dots are not allowed */ + virBufferTrimChars(buf, "-."); +} + +#undef HOSTNAME_CHARS + +char * +virDomainDriverGenerateMachineName(const char *drivername, + const char *root, + int id, + const char *name, + bool privileged) +{ + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + + virBufferAsprintf(&buf, "%s-", drivername); + + if (root) { + g_autofree char *hash =3D NULL; + + /* When two embed drivers start two domains with the same @name an= d @id + * we would generate a non-unique name. Include parts of hashed @r= oot + * which guarantees uniqueness. The first 8 characters of SHA256 o= ught + * to be enough for anybody. */ + if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, root, &hash) < 0) + return NULL; + + virBufferAsprintf(&buf, "embed-%.8s-", hash); + } else if (!privileged) { + g_autofree char *username =3D NULL; + if (!(username =3D virGetUserName(geteuid()))) { + virBufferFreeAndReset(&buf); + return NULL; + } + virBufferAsprintf(&buf, "%s-", username); + } + + virBufferAsprintf(&buf, "%d-", id); + virDomainMachineNameAppendValid(&buf, name); + + return virBufferContentAndReset(&buf); +} + + /* Modify dest_array to reflect all blkio device changes described in * src_array. */ int diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index b6d5e66bba..c52e37f038 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -22,6 +22,13 @@ =20 #include "domain_conf.h" =20 +char * +virDomainDriverGenerateMachineName(const char *drivername, + const char *root, + int id, + const char *name, + bool privileged); + int virDomainDriverMergeBlkioDevice(virBlkioDevicePtr *dest_array, size_t *dest_size, virBlkioDevicePtr src_array, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3f032c7963..69f278f6fb 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -406,7 +406,6 @@ virDomainFSTypeFromString; virDomainFSTypeToString; virDomainFSWrpolicyTypeFromString; virDomainFSWrpolicyTypeToString; -virDomainGenerateMachineName; virDomainGetBlkioParametersAssignFromDef; virDomainGetFilesystemForTarget; virDomainGraphicsAuthConnectedTypeFromString; @@ -1403,6 +1402,7 @@ virDomainCgroupSetupMemtune; =20 =20 # hypervisor/domain_driver.h +virDomainDriverGenerateMachineName; virDomainDriverMergeBlkioDevice; virDomainDriverParseBlkioDeviceStr; virDomainDriverSetupPersistentDefBlkioParams; diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index ebd2c2b56e..59f803837a 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -31,6 +31,7 @@ #include "virtime.h" #include "virsystemd.h" #include "virinitctl.h" +#include "domain_driver.h" =20 #define VIR_FROM_THIS VIR_FROM_LXC =20 @@ -406,7 +407,7 @@ virLXCDomainGetMachineName(virDomainDefPtr def, pid_t p= id) } =20 if (!ret) - ret =3D virDomainGenerateMachineName("lxc", NULL, def->id, def->na= me, true); + ret =3D virDomainDriverGenerateMachineName("lxc", NULL, def->id, d= ef->name, true); =20 return ret; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7d29f3f114..a58d658e0b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -44,6 +44,7 @@ #include "virfile.h" #include "domain_addr.h" #include "domain_capabilities.h" +#include "domain_driver.h" #include "domain_event.h" #include "virtime.h" #include "virnetdevopenvswitch.h" @@ -16537,9 +16538,9 @@ qemuDomainGetMachineName(virDomainObjPtr vm) } =20 if (!ret) - ret =3D virDomainGenerateMachineName("qemu", cfg->root, - vm->def->id, vm->def->name, - virQEMUDriverIsPrivileged(drive= r)); + ret =3D virDomainDriverGenerateMachineName("qemu", cfg->root, + vm->def->id, vm->def->nam= e, + virQEMUDriverIsPrivileged= (driver)); =20 return ret; } diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index 050941dce8..e7dcdea8e9 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -34,6 +34,7 @@ # include "virlog.h" # include "virmock.h" # include "rpc/virnetsocket.h" +# include "domain_driver.h" # define VIR_FROM_THIS VIR_FROM_NONE =20 VIR_LOG_INIT("tests.systemdtest"); @@ -414,8 +415,8 @@ testMachineName(const void *opaque) int ret =3D -1; char *actual =3D NULL; =20 - if (!(actual =3D virDomainGenerateMachineName("qemu", data->root, - data->id, data->name, true= ))) + if (!(actual =3D virDomainDriverGenerateMachineName("qemu", data->root, + data->id, data->name= , true))) goto cleanup; =20 if (STRNEQ(actual, data->expected)) { --=20 2.24.1 From nobody Mon Apr 29 13:23:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585235747; cv=none; d=zohomail.com; s=zohoarc; b=SSG8cNBPYEgv+2YLNpESrdV8cC6BS1IW1bUuDfxU9fpBjwFsrrSxOFnq4Q8fzas2epMumIRkpFzoVUbIPc9boTwi1t65fgl4O4vVZnXvC3sdkiiSmI4DhmA0UOnGCqvhuRYd4x0kuzgvF63itXnCMWP6fsKVI3kvAIouQQcoSH0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585235747; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gccjdSoAQcz9Jgm6eMmSy2Q6O/aJrUdTrLvMYCIaWuU=; b=e3O+IOtkyKqcWUsewoW3iokN54iQa5Whgtjv3A65NmMiYpzGxNmDDPZ9hygYV6si76O+aoEHkK4jTd1xhRZIftyQR/LNIzypqUQM4a4i3GrZjvD06oc3EWRxCB4kGdBf0vLkLCwbEkFoRPKFy6xk1+airaOsD1ZYcZQWfIgcnv8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 158523574735031.79350687538249; Thu, 26 Mar 2020 08:15:47 -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-231-jVMDv4reO6OStmOXVPvRHg-1; Thu, 26 Mar 2020 11:15:44 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 20192192D785; Thu, 26 Mar 2020 15:15:38 +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 D3FAD5C219; Thu, 26 Mar 2020 15:15: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 6DB048A03D; Thu, 26 Mar 2020 15:15:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QFFNnf029008 for ; Thu, 26 Mar 2020 11:15:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id B135C395; Thu, 26 Mar 2020 15:15:23 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EA0519C70 for ; Thu, 26 Mar 2020 15:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585235746; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gccjdSoAQcz9Jgm6eMmSy2Q6O/aJrUdTrLvMYCIaWuU=; b=TDn6j3zCEq+pR70sHEdblRz9h8JFJ76pd8P8qcobVI+M6bhWD+q2uE0wWNaUpKqPPDVZs8 1IJFWVXOM8GL6RFVb1pVS4wAwaolDEogxKWI5yOxiHcVAaVMglrQ+OYc4Gz0By2mEDc7pe W/JGasmrKiUnQuVURbgka2C03wbIX7c= X-MC-Unique: jVMDv4reO6OStmOXVPvRHg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 04/11] virDomainDriverGenerateMachineName: Factor out embed path hashing Date: Thu, 26 Mar 2020 16:15:08 +0100 Message-Id: <44dd849bff34630d14879b1fed196060a40e80cf.1585234828.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" The code that generates "qemu-embed-$hash" is going to be useful in more places. Separate it out into a function. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- src/hypervisor/domain_driver.c | 42 ++++++++++++++++++++++------------ src/hypervisor/domain_driver.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 7bf0fb3f98..31821fc712 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -28,6 +28,22 @@ =20 #define VIR_FROM_THIS VIR_FROM_DOMAIN =20 +char * +virDomainDriverGenerateRootHash(const char *drivername, + const char *root) +{ + g_autofree char *hash =3D NULL; + + if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, root, &hash) < 0) + return NULL; + + /* When two embed drivers start two domains with the same @name and @id + * we would generate a non-unique name. Include parts of hashed @root + * which guarantees uniqueness. The first 8 characters of SHA256 ought + * to be enough for anybody. */ + return g_strdup_printf("%s-embed-%.8s", drivername, hash); +} + =20 #define HOSTNAME_CHARS \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-" @@ -72,26 +88,24 @@ virDomainDriverGenerateMachineName(const char *driverna= me, { virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 - virBufferAsprintf(&buf, "%s-", drivername); - if (root) { g_autofree char *hash =3D NULL; =20 - /* When two embed drivers start two domains with the same @name an= d @id - * we would generate a non-unique name. Include parts of hashed @r= oot - * which guarantees uniqueness. The first 8 characters of SHA256 o= ught - * to be enough for anybody. */ - if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, root, &hash) < 0) + if (!(hash =3D virDomainDriverGenerateRootHash(drivername, root))) return NULL; =20 - virBufferAsprintf(&buf, "embed-%.8s-", hash); - } else if (!privileged) { - g_autofree char *username =3D NULL; - if (!(username =3D virGetUserName(geteuid()))) { - virBufferFreeAndReset(&buf); - return NULL; + virBufferAsprintf(&buf, "%s-", hash); + } else { + virBufferAsprintf(&buf, "%s-", drivername); + if (!privileged) { + + g_autofree char *username =3D NULL; + if (!(username =3D virGetUserName(geteuid()))) { + virBufferFreeAndReset(&buf); + return NULL; + } + virBufferAsprintf(&buf, "%s-", username); } - virBufferAsprintf(&buf, "%s-", username); } =20 virBufferAsprintf(&buf, "%d-", id); diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index c52e37f038..b66ae2d421 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -22,6 +22,10 @@ =20 #include "domain_conf.h" =20 +char * +virDomainDriverGenerateRootHash(const char *drivername, + const char *root); + char * virDomainDriverGenerateMachineName(const char *drivername, const char *root, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 69f278f6fb..58a895a593 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1403,6 +1403,7 @@ virDomainCgroupSetupMemtune; =20 # hypervisor/domain_driver.h virDomainDriverGenerateMachineName; +virDomainDriverGenerateRootHash; virDomainDriverMergeBlkioDevice; virDomainDriverParseBlkioDeviceStr; virDomainDriverSetupPersistentDefBlkioParams; --=20 2.24.1 From nobody Mon Apr 29 13:23:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585235751; cv=none; d=zohomail.com; s=zohoarc; b=l4dP4c0LHuS8l4QTk2WSLkwtz10PYLdeXtOhyE3n1GJF/0xn81ZGtXEwf9eLLnOC+yJLQx94xlFpYDBUP3PksjM+pSDzxAA8IOEJ9FoJ8ir3gzkUmR/OQ4S5Z78XBf+1ED3J/PiH3cXPjGfPgPYFLIYB51xu5Oa5tKz0nheRgbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585235751; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xzNphSqW+wY68YXEczNMHaEq9F7rFrJhFQnrnGYgxZE=; b=CaLKLGBNpk6H16aszVMiLA7m2+PjTu8HrMj7EgvyyQhc2FtXNRGsBKeYK7Ge5RD3GE0DPRCsGOikT0Sg0O5nbkPnXXYnerfhqf/2iqTaPlIYu2TKCx0sGoZQMal8QVna8lhNtP2v3rvwtKBZtKM8Rt4jUBgq6HsS7DB5Cc+X8Dc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1585235751326531.257017320385; Thu, 26 Mar 2020 08:15:51 -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-279-X0NpT_w-Pa2fmHTX2FF6cw-1; Thu, 26 Mar 2020 11:15:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B5AB01088382; Thu, 26 Mar 2020 15:15:41 +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 8342660C81; Thu, 26 Mar 2020 15:15:41 +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 326588A03C; Thu, 26 Mar 2020 15:15:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QFFOpH029017 for ; Thu, 26 Mar 2020 11:15:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 941C3386; Thu, 26 Mar 2020 15:15:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 116BC19C70 for ; Thu, 26 Mar 2020 15:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585235750; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xzNphSqW+wY68YXEczNMHaEq9F7rFrJhFQnrnGYgxZE=; b=B1to3ZSN8Ps2UklA6AJAQmY1kb+BwclRuzcppfNxH5DdjZsVnzMmgN8O0kFV3ECQntxfdy xN3Yw97TYbV37IoIQPGbI2uqplmCmhk+9y1Q23I0s+6yDe6SSmqZlW1nyfW58D0JlpYDdn s1ZScXHXn1l/osNxlQ+XVVXUWFEXxsU= X-MC-Unique: X0NpT_w-Pa2fmHTX2FF6cw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 05/11] qemu: Introduce virQEMUDriverGetEmbedRoot Date: Thu, 26 Mar 2020 16:15:09 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" This function returns embeddedRoot member of the driver structure. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_conf.c | 12 ++++++++++++ src/qemu/qemu_conf.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 9786e19f8f..fdc6f53ad3 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1230,6 +1230,18 @@ virQEMUDriverIsPrivileged(virQEMUDriverPtr driver) return driver->privileged; } =20 +/* virQEMUDriverGetEmbedRoot: + * @driver: the QEMU driver + * + * Returns root directory specified in connection URI for embed + * mode, NULL otherwise. + */ +const char * +virQEMUDriverGetEmbedRoot(virQEMUDriverPtr driver) +{ + return driver->embeddedRoot; +} + virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver, const char *defsecmodel) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index c8d3e439e0..e27ce0b92a 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -334,6 +334,7 @@ virQEMUDriverConfigSetDefaults(virQEMUDriverConfigPtr c= fg); =20 virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver); bool virQEMUDriverIsPrivileged(virQEMUDriverPtr driver); +const char *virQEMUDriverGetEmbedRoot(virQEMUDriverPtr driver); =20 virCapsHostNUMAPtr virQEMUDriverGetHostNUMACaps(virQEMUDriverPtr driver); virCPUDefPtr virQEMUDriverGetHostCPU(virQEMUDriverPtr driver); --=20 2.24.1 From nobody Mon Apr 29 13:23:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585235757; cv=none; d=zohomail.com; s=zohoarc; b=NyW2SdGL4JIurm5e/+2LoZqgdWlDqH0W+LgXa+LpecA9r54OrjgkrQS6xF1Z8hbX7Ibq5Xf9jnd0dg3jzO7wOPwX4m9p5/xKCTr32OnAhYIEsDevLeJA3sK2VgF03OM9BF1hEEeOLdHE7M58xFNAzSc769cSK691bqKzFKb7v7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585235757; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7oWqfDX8mPWUFWScsI51e7iKYWcrpDuzJRqxUFyQROo=; b=nvZZvxcLTQEnsHMDU0pj9GL/dKh/39EFP/McUXv+tcWJHro+GtLQZBQuVjZjnQUsorpunUsjOSwKgpgorHXcBtteYISehJlDrAd+E1uATnXrLC/hG767PcJrHb50fAB/VHua1mpZZ4tFQOZ3zyR2y2DhbWMt9QzFdq9EDcPic5k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 158523575727135.80720782273761; Thu, 26 Mar 2020 08:15:57 -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-112-9uIJoDSePCilHqwhjjF9Mw-1; Thu, 26 Mar 2020 11:15:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 97FF586A078; Thu, 26 Mar 2020 15:15:45 +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 70F4360C63; Thu, 26 Mar 2020 15:15:45 +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 27BB08A045; Thu, 26 Mar 2020 15:15:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QFFP6e029033 for ; Thu, 26 Mar 2020 11:15:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 761DD386; Thu, 26 Mar 2020 15:15:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id E92C819C70 for ; Thu, 26 Mar 2020 15:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585235756; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7oWqfDX8mPWUFWScsI51e7iKYWcrpDuzJRqxUFyQROo=; b=Oo69j/WL6XBvkR2ci6Jtm/mL4I62fpkqAbwmZdm4Hcy2WaGvh1lO1C2ixQbZ3BoYnkUc3n TXsWDR2otK0dqpegvs4/y6PRMaxCKplnocg0emzvaMFqmYWwhg/pNNMz1zwISupXPvXXDv obWVq6mt846uDg6B5Cy75NEfrjkeo+4= X-MC-Unique: 9uIJoDSePCilHqwhjjF9Mw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 06/11] qemuDomainGetMachineName: Access embeddedRoot from driver rather than cfg Date: Thu, 26 Mar 2020 16:15:10 +0100 Message-Id: <49a0c8b74884c4923f4cc4389364a53d90ede3d4.1585234828.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" The cfg->root is going away, therefore get the info right from the driver structure. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a58d658e0b..e71010b7e5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -16528,7 +16528,6 @@ qemuDomainGetMachineName(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; virQEMUDriverPtr driver =3D priv->driver; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); char *ret =3D NULL; =20 if (vm->pid > 0) { @@ -16538,7 +16537,8 @@ qemuDomainGetMachineName(virDomainObjPtr vm) } =20 if (!ret) - ret =3D virDomainDriverGenerateMachineName("qemu", cfg->root, + ret =3D virDomainDriverGenerateMachineName("qemu", + virQEMUDriverGetEmbedRoot= (driver), vm->def->id, vm->def->nam= e, virQEMUDriverIsPrivileged= (driver)); =20 --=20 2.24.1 From nobody Mon Apr 29 13:23:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585235752; cv=none; d=zohomail.com; s=zohoarc; b=IxXJP5TY1BWaWXo+E4JmtPwqgIrb85BCb165Jl1JXpnc3KDC1V2LUXLmKUvoyTjVStTG5rrxtDkVpav38QG7j2sv8PG+Aofm1VLMHHtBDyUIUv2oQ1Dta6KX10zyT5TNgvplJn9qseOWbPo5F4ub7NBHnP6fRuVIwMrd1WqeaW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585235752; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pgmL+nisCVdRm8+64762c7jik8tEjQjJkL85Pz/NE80=; b=MYAk8F+zyNkxDu6p+oRDKclgDx21qSLUowWbJVHT+umQth72YO3do5wodXDmaJs6TuhfMG2FKpIK5uRwE9ccFT2BF2ZF9PAE/hq4yRx+Oz+iiQ55ZokLYLQnNMlNxoI1mxrm+8oQMVPREpib0PtI6iGl60GfJed8kmxDgbch02o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1585235752002751.7089437211205; Thu, 26 Mar 2020 08:15:52 -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-416-Xbv4BLblPiq5CoAowI2ItQ-1; Thu, 26 Mar 2020 11:15:48 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5BCB113F5; Thu, 26 Mar 2020 15:15:42 +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 272DE19C70; Thu, 26 Mar 2020 15:15:42 +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 CA57818089C8; Thu, 26 Mar 2020 15:15:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QFFQ4G029043 for ; Thu, 26 Mar 2020 11:15:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A76A386; Thu, 26 Mar 2020 15:15:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB68619C70 for ; Thu, 26 Mar 2020 15:15:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585235750; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=pgmL+nisCVdRm8+64762c7jik8tEjQjJkL85Pz/NE80=; b=IDMP1zmlqRvvq6GiE1o6BKPbWUaazyVTlgku+nRxE0pE/S+shRXTgWbR11qQAlfuKS+lXO B4O6V5Yk55vdhbKVHnsMDn1YaPdkdM8IFjsoeudKtW8yzvbLPeeencW6IY+NEyHsa2KcBp QTCoYf7FffqcT56pdT7rkm4fplR1GnY= X-MC-Unique: Xbv4BLblPiq5CoAowI2ItQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 07/11] qemu: use virQEMUDriverGetEmbedRoot() to access embeddedRoot Date: Thu, 26 Mar 2020 16:15:11 +0100 Message-Id: <3308cec2a5681fe436ea050f726a638047cfd172.1585234828.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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" Now that we have shiny accessor for driver->embeddedRoot use it instead of accessing the struct member directly. Signed-off-by: Michal Privoznik --- src/qemu/qemu_driver.c | 6 +++--- src/qemu/qemu_process.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5cbf2f2478..664ea4eeda 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1173,7 +1173,7 @@ static virDrvOpenStatus qemuConnectOpen(virConnectPtr= conn, return VIR_DRV_OPEN_ERROR; } =20 - if (qemu_driver->embeddedRoot) { + if (virQEMUDriverGetEmbedRoot(qemu_driver)) { const char *root =3D virURIGetParam(conn->uri, "root"); if (!root) return VIR_DRV_OPEN_ERROR; @@ -1184,11 +1184,11 @@ static virDrvOpenStatus qemuConnectOpen(virConnectP= tr conn, return VIR_DRV_OPEN_ERROR; } =20 - if (STRNEQ(root, qemu_driver->embeddedRoot)) { + if (STRNEQ(root, virQEMUDriverGetEmbedRoot(qemu_driver))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot open embedded driver at path '%s', " "already open with path '%s'"), - root, qemu_driver->embeddedRoot); + root, virQEMUDriverGetEmbedRoot(qemu_driver)); return VIR_DRV_OPEN_ERROR; } } else { diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index fcb47e8596..b0b2258850 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6715,7 +6715,7 @@ qemuProcessLaunch(virConnectPtr conn, _("Domain autodestroy requires a connection han= dle")); return -1; } - if (driver->embeddedRoot) { + if (virQEMUDriverGetEmbedRoot(driver)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Domain autodestroy not supported for embedde= d drivers yet")); return -1; --=20 2.24.1 From nobody Mon Apr 29 13:23:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585235760; cv=none; d=zohomail.com; s=zohoarc; b=FlhkEA8cyB6TjkSPtpG6JS8BNMKPombLVXCWSN7s7Yhohgw5EMZfB2vvSYd/5sRoyOO8BUIK0Z7jGrIeSXU+qkqm2D5KEfC/KzkJnRMkPqWGSO93V3QykCZj7BzXw1zERlXpbQBPjbX7iSRY4fEmKWZf9YZrVZSL/XW1M7cEqjs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585235760; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9wMm9+jJejb32eiH8OamXKynOo/hX8Gwq40SR3qrkiY=; b=J/hM9A3H4uEDJM/cJZPb5IBAO3bMcbCJPgnmhbmqnhydjJBh2ciCciqB4QkJXQIwneJ98JKRx4mLTLAuXKZtI+SwBXJDC+hRumQxGGZBF3azEPPS+Wjft7aQyyxDhI/9dvtt/cHxdRovy5Zhm1ghkLLRBRboZB/mwFEXGF3Q/Uk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1585235760491531.5494357811558; Thu, 26 Mar 2020 08:16:00 -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-236-uiHPA9VvOOS86hmNY9iRbg-1; Thu, 26 Mar 2020 11:15:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6D414107ACC7; Thu, 26 Mar 2020 15:15:49 +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 40E265DA7B; Thu, 26 Mar 2020 15:15:49 +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 EB5B08A04B; Thu, 26 Mar 2020 15:15:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QFFRTf029048 for ; Thu, 26 Mar 2020 11:15:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3E593386; Thu, 26 Mar 2020 15:15:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0C3819C70 for ; Thu, 26 Mar 2020 15:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585235759; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9wMm9+jJejb32eiH8OamXKynOo/hX8Gwq40SR3qrkiY=; b=GSzOVJLyZWcRzgO1qM9sTTybfWTrmubyHbO9LsWP4Ip/jytoPP7i6eYLmK5FzB94h6A9jj NycSSRYN5qbSMRb79ib5QbHoVE0Btkv8kvnZcQnMLCH2V+s5ibYeTCmykCBfcIYXPsOb04 zk+UBQabefdEgXi662bHwd9JB4xM2YQ= X-MC-Unique: uiHPA9VvOOS86hmNY9iRbg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 08/11] Revert "qemu_conf: Track embed root dir" Date: Thu, 26 Mar 2020 16:15:12 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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" This reverts commit 06a19921b6a522cd7b4d352c9320909752947de3. What I haven't realized when writing this ^^ commit is that the virQEMUDriver structure already stores the root directory path. And since the pointer is immutable it can be accessed right from the structure and thus there is no need to duplicate it in the driver config. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_conf.c | 2 -- src/qemu/qemu_conf.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index fdc6f53ad3..3782c2b43b 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -115,7 +115,6 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool priv= ileged, =20 if (root) { cfg->uri =3D g_strdup_printf("qemu:///embed?root=3D%s", root); - cfg->root =3D g_strdup(root); } else { cfg->uri =3D g_strdup(privileged ? "qemu:///system" : "qemu:///ses= sion"); } @@ -302,7 +301,6 @@ static void virQEMUDriverConfigDispose(void *obj) =20 virStringListFree(cfg->cgroupDeviceACL); VIR_FREE(cfg->uri); - VIR_FREE(cfg->root); =20 VIR_FREE(cfg->configBaseDir); VIR_FREE(cfg->configDir); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index e27ce0b92a..76669e2139 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -76,8 +76,6 @@ struct _virQEMUDriverConfig { virObject parent; =20 char *uri; - char *root; /* The root directory for embed driver, - NULL for system/session connections */ =20 uid_t user; gid_t group; --=20 2.24.1 From nobody Mon Apr 29 13:23:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585235796; cv=none; d=zohomail.com; s=zohoarc; b=OnNtTUv4KR6QhEoNl0QnCLIazEPpwYefORh1rq9VSUsjP+J169qarC0efOd8eidGwuGyOuujZKM1QomWifSsftysvHGBy2hkPIbgq+PgQpEr9IB44hHyS3RnjQ1L1jKlxwaFR8XHNggHnuwfNXjlIsDfxuR9SnWI9pJouw1haoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585235796; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ey54wuLp+zE/zdXDYF+iB/CnD5+zCAwkv1mslo1BR0k=; b=dvI0a1ywMdbd/S356WppBM3HYdMhJomzrQ2em+djJVzk/G5Ox7lg/CB3j9soWi5p2hlvg/QD2B2vvwAsneoUZx68QJn5tcJ9NSrPq0QHVswCJnL1Ab4PyeoxvKZOgKnmn3Oj7VX1hfdbmqn8VDZLMLP5K/kLvOVLV5uIT/24ozs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1585235796562748.1664596287512; Thu, 26 Mar 2020 08:16:36 -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-221-X1tp_h1-OLi1oQ2yrAKvYg-1; Thu, 26 Mar 2020 11:16:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2FA22107B769; Thu, 26 Mar 2020 15:16: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 F39F05E001; Thu, 26 Mar 2020 15:16:26 +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 970F386380; Thu, 26 Mar 2020 15:16:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QFFS7Z029059 for ; Thu, 26 Mar 2020 11:15:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1FB77386; Thu, 26 Mar 2020 15:15:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9353F19C70 for ; Thu, 26 Mar 2020 15:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585235795; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ey54wuLp+zE/zdXDYF+iB/CnD5+zCAwkv1mslo1BR0k=; b=Tl4s4P/SXe5fh4rO/jCoSkHwMBkPuTD3fT9e6lFHIplYbZB9sjg0gssaG/m79G7NhaAIEX R7Crt7sQFw9Rn+/uFGJimWAz673iZQxky9aPqJ4pR9p7lU78EVHS3PTQyumDIGlOKpcmgB 58SVYCn4rfy+jnw9STyQ/lm3Z0YpzJ8= X-MC-Unique: X1tp_h1-OLi1oQ2yrAKvYg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 09/11] qemu: Make hugepages path generation embed driver aware Date: Thu, 26 Mar 2020 16:15:13 +0100 Message-Id: <208722d7f0c2d959f29ff6ef486420e3d6fe04ce.1585234828.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" So far, libvirt generates the following path for hugepages: $mnt/libvirt/qemu/$id-$shortName where $mnt is the mount point of hugetlbfs corresponding to hugepages of desired size (e.g. /dev/hugepages), $id is domain ID and $shortName is shortened version of domain name. So for instance, the generated path may look something like this: /dev/hugepages/libvirt/qemu/1-QEMUGuest But this won't work with embed driver really, because if there are two instances of embed driver, and they both want to start a domain with the same name and with hugepages, both drivers will generate the same path which is not desired. Fortunately, we can reuse the approach for machined name generation (v6.1.0-178-gc9bd08ee35) and include part of hash of the root in the generated path. Note, the important change is in qemuGetBaseHugepagePath(). The rest is needed to pass driver around. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 4 ++-- src/qemu/qemu_conf.c | 24 +++++++++++++++++------- src/qemu/qemu_conf.h | 10 ++++++---- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d1b689dfd3..9afb59828c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3465,7 +3465,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendP= rops, if (!priv->memPrealloc) prealloc =3D true; } else if (useHugepage) { - if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) <= 0) + if (qemuGetDomainHupageMemPath(priv->driver, def, pagesize, &m= emPath) < 0) return -1; if (!priv->memPrealloc) prealloc =3D true; @@ -7251,7 +7251,7 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg, if (!pagesize && qemuBuildMemoryGetDefaultPagesize(cfg, &pagesize) < 0) return -1; - if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &mem_path) < 0) + if (qemuGetDomainHupageMemPath(priv->driver, def, pagesize, &mem_p= ath) < 0) return -1; } else if (def->mem.source =3D=3D VIR_DOMAIN_MEMORY_SOURCE_FILE) { if (qemuGetMemoryBackingPath(def, cfg, "ram", &mem_path) < 0) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3782c2b43b..de2a52adb3 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -40,6 +40,7 @@ #include "virxml.h" #include "virlog.h" #include "cpu/cpu.h" +#include "domain_driver.h" #include "domain_nwfilter.h" #include "virfile.h" #include "virsocket.h" @@ -1894,21 +1895,29 @@ qemuTranslateSnapshotDiskSourcePool(virDomainSnapsh= otDiskDefPtr def) } =20 char * -qemuGetBaseHugepagePath(virHugeTLBFSPtr hugepage) +qemuGetBaseHugepagePath(virQEMUDriverPtr driver, + virHugeTLBFSPtr hugepage) { + const char *root =3D virQEMUDriverGetEmbedRoot(driver); char *ret; =20 - ret =3D g_strdup_printf("%s/libvirt/qemu", hugepage->mnt_dir); + if (root && !STRPREFIX(hugepage->mnt_dir, root)) { + g_autofree char * hash =3D virDomainDriverGenerateRootHash("qemu",= root); + ret =3D g_strdup_printf("%s/libvirt/%s", hugepage->mnt_dir, hash); + } else { + ret =3D g_strdup_printf("%s/libvirt/qemu", hugepage->mnt_dir); + } =20 return ret; } =20 =20 char * -qemuGetDomainHugepagePath(const virDomainDef *def, +qemuGetDomainHugepagePath(virQEMUDriverPtr driver, + const virDomainDef *def, virHugeTLBFSPtr hugepage) { - g_autofree char *base =3D qemuGetBaseHugepagePath(hugepage); + g_autofree char *base =3D qemuGetBaseHugepagePath(driver, hugepage); g_autofree char *domPath =3D virDomainDefGetShortName(def); char *ret =3D NULL; =20 @@ -1927,11 +1936,12 @@ qemuGetDomainHugepagePath(const virDomainDef *def, * -1 otherwise. */ int -qemuGetDomainHupageMemPath(const virDomainDef *def, - virQEMUDriverConfigPtr cfg, +qemuGetDomainHupageMemPath(virQEMUDriverPtr driver, + const virDomainDef *def, unsigned long long pagesize, char **memPath) { + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); size_t i =3D 0; =20 if (!cfg->nhugetlbfs) { @@ -1954,7 +1964,7 @@ qemuGetDomainHupageMemPath(const virDomainDef *def, return -1; } =20 - if (!(*memPath =3D qemuGetDomainHugepagePath(def, &cfg->hugetlbfs[i]))) + if (!(*memPath =3D qemuGetDomainHugepagePath(driver, def, &cfg->hugetl= bfs[i]))) return -1; =20 return 0; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 76669e2139..0099ac5be4 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -388,12 +388,14 @@ virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQ= EMUDriverPtr driver, =20 int qemuTranslateSnapshotDiskSourcePool(virDomainSnapshotDiskDefPtr def); =20 -char * qemuGetBaseHugepagePath(virHugeTLBFSPtr hugepage); -char * qemuGetDomainHugepagePath(const virDomainDef *def, +char * qemuGetBaseHugepagePath(virQEMUDriverPtr driver, + virHugeTLBFSPtr hugepage); +char * qemuGetDomainHugepagePath(virQEMUDriverPtr driver, + const virDomainDef *def, virHugeTLBFSPtr hugepage); =20 -int qemuGetDomainHupageMemPath(const virDomainDef *def, - virQEMUDriverConfigPtr cfg, +int qemuGetDomainHupageMemPath(virQEMUDriverPtr driver, + const virDomainDef *def, unsigned long long pagesize, char **memPath); =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 664ea4eeda..0033a72d0b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -917,7 +917,7 @@ qemuStateInitialize(bool privileged, for (i =3D 0; i < cfg->nhugetlbfs; i++) { g_autofree char *hugepagePath =3D NULL; =20 - hugepagePath =3D qemuGetBaseHugepagePath(&cfg->hugetlbfs[i]); + hugepagePath =3D qemuGetBaseHugepagePath(qemu_driver, &cfg->hugetl= bfs[i]); =20 if (!hugepagePath) goto error; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b0b2258850..aa6741e1f4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3881,7 +3881,7 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr d= river, if (!build || shouldBuildHP) { for (i =3D 0; i < cfg->nhugetlbfs; i++) { g_autofree char *path =3D NULL; - path =3D qemuGetDomainHugepagePath(vm->def, &cfg->hugetlbfs[i]= ); + path =3D qemuGetDomainHugepagePath(driver, vm->def, &cfg->huge= tlbfs[i]); =20 if (!path) return -1; --=20 2.24.1 From nobody Mon Apr 29 13:23:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585235830; cv=none; d=zohomail.com; s=zohoarc; b=KYgZoItvnnVSsg7Yue8UfmvZm5+7FIWaaqHpVMa70Tp/QxPjO3XEc7l8wIuyJUUZK5ngntHqMQe8YVShVlkdJCJhhzuoXuLzDEQeKx/Fe0+uLCk8N3gpah1tjfXPjzPC9R3iXYWILACABkPTeIpiN/sImDIPlcKWIUDWF8QXbew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585235830; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=H3IRENnUZdy65Iw+W1ivGmgbcahMVgOKDSU/+Zug/As=; b=mzZwsNWV0Gdfpep8twsutRXOopXQjojH8mYjHRuINchBHE4bfbxdkvG2STE9rYoMGCBCHuiB5AOKheEuZKf9bAxXyRcCe1VhkPqI+oxv9rE245CpdruGlU3tEPXqReGZKUUsDcc4sljCvSVHoHdjNvP3aoQFBJatPldp38DvaS0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1585235830981575.1699967952017; Thu, 26 Mar 2020 08:17:10 -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-260-S_kbgsuPMaqmod7UyoxgVA-1; Thu, 26 Mar 2020 11:16:00 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D3791403; Thu, 26 Mar 2020 15:15:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A2CE398; Thu, 26 Mar 2020 15:15:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 102CF18089CE; Thu, 26 Mar 2020 15:15:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QFFTpR029076 for ; Thu, 26 Mar 2020 11:15:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0241A386; Thu, 26 Mar 2020 15:15:29 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7499419C70 for ; Thu, 26 Mar 2020 15:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585235829; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=H3IRENnUZdy65Iw+W1ivGmgbcahMVgOKDSU/+Zug/As=; b=AxGCr1yG/uo30yQIbTutynrw9WzTgjjrBi1otLfEuia12DjSboS0WcOaEo0opTQR03+wrv 2gtiQQB9zYoRWWd5ItWT4E4zqQgq8ylBQCdcop5GhB3AMhXcFsnL1G2RLk4T/CFCkG/gtn crs4oXVI6xrqDHpPukDNZvsFyxdLaDI= X-MC-Unique: S_kbgsuPMaqmod7UyoxgVA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 10/11] qemu: Make memory path generation embed driver aware Date: Thu, 26 Mar 2020 16:15:14 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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" So far, libvirt generates the following path for memory: $memoryBackingDir/$id-$shortName/ram-nodeN where $memoryBackingDir is the path where QEMU mmaps() memory for the guest (e.g. /var/lib/libvirt/qemu/ram), $id is domain ID and $shortName is shortened version of domain name. So for instance, the generated path may look something like this: /var/lib/libvirt/qemu/ram/1-QEMUGuest/ram-node0 While in case of embed driver the following path would be generated by default: $root/lib/qemu/ram/1-QEMUGuest/ram-node0 which is not clashing with other embed drivers, we allow users to override the default and have all embed drivers use the same prefix. This can create clashing paths. Fortunately, we can reuse the approach for machined name generation (v6.1.0-178-gc9bd08ee35) and include part of hash of the root in the generated path. Note, the important change is in qemuGetMemoryBackingBasePath(). The rest is needed to pass driver around. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 15 +++++++-------- src/qemu/qemu_conf.c | 21 ++++++++++++++------- src/qemu/qemu_conf.h | 8 ++++---- src/qemu/qemu_process.c | 5 ++--- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9afb59828c..308c32f4ee 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3472,7 +3472,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendP= rops, } else { /* We can have both pagesize and mem source. If that's the cas= e, * prefer hugepages as those are more specific. */ - if (qemuGetMemoryBackingPath(def, cfg, mem->info.alias, &memPa= th) < 0) + if (qemuGetMemoryBackingPath(priv->driver, def, mem->info.alia= s, &memPath) < 0) return -1; } =20 @@ -7233,11 +7233,11 @@ qemuBuildSmpCommandLine(virCommandPtr cmd, =20 =20 static int -qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg, - const virDomainDef *def, +qemuBuildMemPathStr(const virDomainDef *def, virCommandPtr cmd, qemuDomainObjPrivatePtr priv) { + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(priv->dr= iver); const long system_page_size =3D virGetSystemPageSizeKB(); g_autofree char *mem_path =3D NULL; =20 @@ -7254,7 +7254,7 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg, if (qemuGetDomainHupageMemPath(priv->driver, def, pagesize, &mem_p= ath) < 0) return -1; } else if (def->mem.source =3D=3D VIR_DOMAIN_MEMORY_SOURCE_FILE) { - if (qemuGetMemoryBackingPath(def, cfg, "ram", &mem_path) < 0) + if (qemuGetMemoryBackingPath(priv->driver, def, "ram", &mem_path) = < 0) return -1; } else { return 0; @@ -7273,7 +7273,6 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg, =20 static int qemuBuildMemCommandLine(virCommandPtr cmd, - virQEMUDriverConfigPtr cfg, const virDomainDef *def, virQEMUCapsPtr qemuCaps, qemuDomainObjPrivatePtr priv) @@ -7305,7 +7304,7 @@ qemuBuildMemCommandLine(virCommandPtr cmd, * the hugepages and no numa node is specified. */ if (!virDomainNumaGetNodeCount(def->numa) && - qemuBuildMemPathStr(cfg, def, cmd, priv) < 0) + qemuBuildMemPathStr(def, cmd, priv) < 0) return -1; =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OVERCOMMIT)) { @@ -7386,7 +7385,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, } =20 if (!needBackend && - qemuBuildMemPathStr(cfg, def, cmd, priv) < 0) + qemuBuildMemPathStr(def, cmd, priv) < 0) goto cleanup; =20 for (i =3D 0; i < ncells; i++) { @@ -9879,7 +9878,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (!migrateURI && !snapshot && qemuDomainAlignMemorySizes(def) < 0) return NULL; =20 - if (qemuBuildMemCommandLine(cmd, cfg, def, qemuCaps, priv) < 0) + if (qemuBuildMemCommandLine(cmd, def, qemuCaps, priv) < 0) return NULL; =20 if (qemuBuildSmpCommandLine(cmd, def, qemuCaps) < 0) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index de2a52adb3..7f0c915bd1 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1972,16 +1972,23 @@ qemuGetDomainHupageMemPath(virQEMUDriverPtr driver, =20 =20 int -qemuGetMemoryBackingDomainPath(const virDomainDef *def, - virQEMUDriverConfigPtr cfg, +qemuGetMemoryBackingDomainPath(virQEMUDriverPtr driver, + const virDomainDef *def, char **path) { + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + const char *root =3D virQEMUDriverGetEmbedRoot(driver); g_autofree char *shortName =3D NULL; =20 if (!(shortName =3D virDomainDefGetShortName(def))) return -1; =20 - *path =3D g_strdup_printf("%s/%s", cfg->memoryBackingDir, shortName); + if (root && !STRPREFIX(cfg->memoryBackingDir, root)) { + g_autofree char * hash =3D virDomainDriverGenerateRootHash("qemu",= root); + *path =3D g_strdup_printf("%s/%s-%s", cfg->memoryBackingDir, hash,= shortName); + } else { + *path =3D g_strdup_printf("%s/%s", cfg->memoryBackingDir, shortNam= e); + } =20 return 0; } @@ -1989,8 +1996,8 @@ qemuGetMemoryBackingDomainPath(const virDomainDef *de= f, =20 /** * qemuGetMemoryBackingPath: + * @driver: the qemu driver * @def: domain definition - * @cfg: the driver config * @alias: memory object alias * @memPath: constructed path * @@ -2000,8 +2007,8 @@ qemuGetMemoryBackingDomainPath(const virDomainDef *de= f, * -1 otherwise (with error reported). */ int -qemuGetMemoryBackingPath(const virDomainDef *def, - virQEMUDriverConfigPtr cfg, +qemuGetMemoryBackingPath(virQEMUDriverPtr driver, + const virDomainDef *def, const char *alias, char **memPath) { @@ -2014,7 +2021,7 @@ qemuGetMemoryBackingPath(const virDomainDef *def, return -1; } =20 - if (qemuGetMemoryBackingDomainPath(def, cfg, &domainPath) < 0) + if (qemuGetMemoryBackingDomainPath(driver, def, &domainPath) < 0) return -1; =20 *memPath =3D g_strdup_printf("%s/%s", domainPath, alias); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 0099ac5be4..31c23f7638 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -399,10 +399,10 @@ int qemuGetDomainHupageMemPath(virQEMUDriverPtr drive= r, unsigned long long pagesize, char **memPath); =20 -int qemuGetMemoryBackingDomainPath(const virDomainDef *def, - virQEMUDriverConfigPtr cfg, +int qemuGetMemoryBackingDomainPath(virQEMUDriverPtr driver, + const virDomainDef *def, char **path); -int qemuGetMemoryBackingPath(const virDomainDef *def, - virQEMUDriverConfigPtr cfg, +int qemuGetMemoryBackingPath(virQEMUDriverPtr driver, + const virDomainDef *def, const char *alias, char **memPath); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index aa6741e1f4..c1250ef66c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3894,7 +3894,7 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr d= river, =20 if (!build || shouldBuildMB) { g_autofree char *path =3D NULL; - if (qemuGetMemoryBackingDomainPath(vm->def, cfg, &path) < 0) + if (qemuGetMemoryBackingDomainPath(driver, vm->def, &path) < 0) return -1; =20 if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm, @@ -3911,10 +3911,9 @@ qemuProcessDestroyMemoryBackingPath(virQEMUDriverPtr= driver, virDomainObjPtr vm, virDomainMemoryDefPtr mem) { - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autofree char *path =3D NULL; =20 - if (qemuGetMemoryBackingPath(vm->def, cfg, mem->info.alias, &path) < 0) + if (qemuGetMemoryBackingPath(driver, vm->def, mem->info.alias, &path) = < 0) return -1; =20 if (unlink(path) < 0 && --=20 2.24.1 From nobody Mon Apr 29 13:23:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585235884; cv=none; d=zohomail.com; s=zohoarc; b=FhHf5qc+BIt2J2rxh1h2JAA7aXCtoibJzltf0R34EM+QQKNRMPW8NegF0WHcLrzTV0dfpZNGE57RlodrIgupCCWWz8QdpCe0wcBqi5eTEmsgSChc5o2+Loxv+mg8PGvdrd6sqpJrINB92tE3aMDPro2/ThHh2bSRWbHe1MD6CN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585235884; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a20YP8e6RDkHArzvosXx6bqwr2t+vZNPS3N9kdnLggc=; b=iWhaam5jCxP6dzfVbDhTxe00fvVtLS1kWkluNkXN/KWwcNrMUwTADAbciRjRTUhHgLvrVqBHhYMv3OlRPcz5DSLUO63Ct05EUa9moOw4CJGgnR37fjiuPQFp17AUwlRBy1gkDhei0LigyyVVt07u0SfQRqo4QDkLFvhFzrV81Yk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1585235884606686.2483332648799; Thu, 26 Mar 2020 08:18:04 -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-179-9EroneeaOR-b3D4gXukaRw-1; Thu, 26 Mar 2020 11:16:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 861758018A1; Thu, 26 Mar 2020 15:16:31 +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 50FA060C63; Thu, 26 Mar 2020 15:16:31 +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 F337C18089D0; Thu, 26 Mar 2020 15:16:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QFFTGr029086 for ; Thu, 26 Mar 2020 11:15:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id D957A398; Thu, 26 Mar 2020 15:15:29 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 589F419C70 for ; Thu, 26 Mar 2020 15:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585235883; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=a20YP8e6RDkHArzvosXx6bqwr2t+vZNPS3N9kdnLggc=; b=KdTxxe2UFjLkpj21aPjmXQuHddXkutIjMdaNNP95VP7VU5yU6rYdBg14CLrVba2R8wQYKC kw+0O2SdYO8g56yvWHkMbTJ7eZtx1QB3Bv7moT8AovwFB955OS991VeiufJwa9/8G+rDVP JhS7NTwz12MiiLQzUaHSeq/PkU4z86Y= X-MC-Unique: 9EroneeaOR-b3D4gXukaRw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 11/11] qemu: Make auto dump path generation embed driver aware Date: Thu, 26 Mar 2020 16:15:15 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" So far, libvirt generates the following path for automatic dumps: $autoDumpPath/$id-$shortName-$timestamp where $autoDumpPath is where libvirt stores dumps of guests (e.g. /var/lib/libvirt/qemu/dump), $id is domain ID and $shortName is shortened version of domain name. So for instance, the generated path may look something like this: /var/lib/libvirt/qemu/dump/1-QEMUGuest-2020-03-25-10:40:50 While in case of embed driver the following path would be generated by default: $root/lib/libvirt/qemu/dump/1-QEMUGuest-2020-03-25-10:40:50 which is not clashing with other embed drivers, we allow users to override the default and have all embed drivers use the same prefix. This can create clashing paths. Fortunately, we can reuse the approach for machined name generation (v6.1.0-178-gc9bd08ee35) and include part of hash of the root in the generated path. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_driver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0033a72d0b..36b94f3f1b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4104,6 +4104,7 @@ static char * getAutoDumpPath(virQEMUDriverPtr driver, virDomainObjPtr vm) { + const char *root =3D virQEMUDriverGetEmbedRoot(driver); g_autofree char *domname =3D virDomainDefGetShortName(vm->def); g_autoptr(GDateTime) now =3D g_date_time_new_now_local(); g_autofree char *nowstr =3D NULL; @@ -4116,6 +4117,11 @@ getAutoDumpPath(virQEMUDriverPtr driver, =20 nowstr =3D g_date_time_format(now, "%Y-%m-%d-%H:%M:%S"); =20 + if (root && !STRPREFIX(cfg->autoDumpPath, root)) { + g_autofree char * hash =3D virDomainDriverGenerateRootHash(QEMU_DR= IVER_NAME, root); + return g_strdup_printf("%s/%s-%s-%s", cfg->autoDumpPath, hash, dom= name, nowstr); + } + return g_strdup_printf("%s/%s-%s", cfg->autoDumpPath, domname, nowstr); } =20 --=20 2.24.1