From nobody Sat Feb 7 11:42:14 2026 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=1585131512; cv=none; d=zohomail.com; s=zohoarc; b=jWL0Y2lMDSM24V4WHvBVDcrBiHXuS2wiCNkeGCW9vlaxKzXcAzWMvOwQmE5+XEkjiij9L4ZvzAqiGoa0FVV3nbexOMUohd6cDXanv25wz8/jpi75lJs9AAQEIFR+xSuNHhukPtc9BwWm4ptqdnzo+rol+PF/KBWunkZAmMyGL+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585131512; 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=csFrDRaWRyzE1gN6334KNEI1jEXb3W65NcFDoMKzHyk=; b=WF0m9AxAyFmOFMVujDrW4m5PYphVsUb1WcXMCPOFGno0SYQA9eZCioe1RJAjXVfOAHnwsKgkS8FnjUo8T6rqhPtpwtroHX2uZmtf3G8GRdnrn9f9SIfNLgJu8ATEJCLxpkdBjpNcjH90AUbkybNwQy5zIBWrZ+M3/NW6ixlrxf8= 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 1585131512383422.3144902245474; Wed, 25 Mar 2020 03:18:32 -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-321-1ZiuROvnMg-QinoaS4rbhA-1; Wed, 25 Mar 2020 06:18:29 -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 11044107ACCA; Wed, 25 Mar 2020 10:18:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9014F953AB; Wed, 25 Mar 2020 10:18:22 +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 BAEBF944C4; Wed, 25 Mar 2020 10:18:19 +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 02PAIHRO000348 for ; Wed, 25 Mar 2020 06:18:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 08ED7385; Wed, 25 Mar 2020 10:18:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C9FB46 for ; Wed, 25 Mar 2020 10:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585131511; 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=csFrDRaWRyzE1gN6334KNEI1jEXb3W65NcFDoMKzHyk=; b=FhX4SrJzDkSFVi5+U9z0n3DGYA/SRhjLr1RP8JWYIayIJr1Cm/N9LtK6DvQHtHZn531q4F FSSHKO87Wn6U7vH4UzpbpMDmvpBW+O8h2AEggsKaopY05k8I+rZNp7aO8li7XKBus0SB6h xcGpVcZprjAwX7wgUjET9ewxNnweZuw= X-MC-Unique: 1ZiuROvnMg-QinoaS4rbhA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/9] tests: Fix virQEMUDriverConfigNew() calling with respect to @root Date: Wed, 25 Mar 2020 11:18:01 +0100 Message-Id: <166ddd3346bc17e7e80fb2728b7c0033ec5fcbbf.1585130420.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" 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 --- 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 Sat Feb 7 11:42:14 2026 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=1585131513; cv=none; d=zohomail.com; s=zohoarc; b=hjs45GlF75JQjHM3zith//efZQyJdJSTu6IcVjgwJjuh1L+TyXUOF7oEWCs5noEMPCrhO6n1nbMMQdldVLjP5KLRpnjITQmDDtQ+I9jnTaGhUjsHW+Gq1R15OGdQr4Gy8UQzoH11o9ani9NRegwh9MXbYfDlXJvmmL+LuQe+BTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585131513; 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=qDYk1kJlF6ZKdBIqKe8eM4vXE2No8js12f0BCOdFOBM=; b=lsR3pcldxGwt6mfFke8NdE0rpGimh/ln7explB7yZhWAH/ZxlgFud4humnDX1qyRUr9C/gZ/3z4K8P1frmo8bxIo25ERitUN86Jg+EaoTMR9in7lLOBtkO2KJ63oRCv/aTx7Nm5+9Bv6MLuXDkfaBhl8AO9CeO4Rhl2trKgwC4o= 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 15851315135581023.1733951350691; Wed, 25 Mar 2020 03:18:33 -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-444-7kh5kZ8oOse79wf7aPBfGA-1; Wed, 25 Mar 2020 06:18:28 -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 35259107ACCC; Wed, 25 Mar 2020 10:18:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8FC005C28E; Wed, 25 Mar 2020 10:18:22 +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 F4101944BD; Wed, 25 Mar 2020 10:18:18 +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 02PAIIBU000358 for ; Wed, 25 Mar 2020 06:18:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 15C1E385; Wed, 25 Mar 2020 10:18:18 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E7D9194BB for ; Wed, 25 Mar 2020 10:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585131512; 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=qDYk1kJlF6ZKdBIqKe8eM4vXE2No8js12f0BCOdFOBM=; b=IH5sLlZL5xlyzduii7tRExE0nCHRRU+SnqrsJ3+JFnxCGJlaSPXGZWNXoFERT+OnZTQL82 d36h/mcXwkazhTX34mFjIi2ArEB3uGjj4n3WjItVOHR6N+VZ3HkiQBsBxdDPEqrxZcWCyv qBsUpTaHF3fU8d5+3O5ZIBt4exufN+0= X-MC-Unique: 7kh5kZ8oOse79wf7aPBfGA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/9] conf: Move virDomainGenerateMachineName to hypervisor/ Date: Wed, 25 Mar 2020 11:18:02 +0100 Message-Id: <11ec6208f5dc9d999e306b9a422630ac4fae97fb.1585130420.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 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 --- 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 2c9fb47d17..b921126e1c 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" @@ -16490,9 +16491,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 Sat Feb 7 11:42:14 2026 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=1585131533; cv=none; d=zohomail.com; s=zohoarc; b=JoiwIQrDfb7wuPJcBF2jaOJ33Iiy3H2UEUtTtDGxspXohyU6NWbwO9ElWdBOmEmt93hSykaim9wgqIs8QgpaG/BkqsfcoHiwIpb6DsorVykKJl8nsIWEsec7XeHcReXSzLVIKhw7HHmKJO4UWJJRbCy3Wrt5e96AGMr1KlzU1OA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585131533; 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=VIRj7R2wbbl+ArrhTmST/spZSVgNd6lOF/KyDrpg4A8=; b=cF4RdnGBuzUn7Qzj1PDZrJ1P6KqyvdW9zH9EnPLhqk6W7gBcaqfBCMX7YrBh6eng0YUjSO4CC+o4ub0xNB22hqKzUqf8mEA8pXEtXPSokCPLFa4BystGuQKIRV8FJ6M4uNQRwVu3lOk6ro9CVHtDw/mBGtrbRuhxJasIlCCBNA4= 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 1585131533341489.553279318303; Wed, 25 Mar 2020 03:18:53 -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-214-c5piV4axNkqMEN8RokDILQ-1; Wed, 25 Mar 2020 06:18:50 -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 E49FF107ACCD; Wed, 25 Mar 2020 10:18:44 +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 B994860BE1; Wed, 25 Mar 2020 10:18:44 +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 6774218089CF; Wed, 25 Mar 2020 10:18:44 +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 02PAIIoU000364 for ; Wed, 25 Mar 2020 06:18:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id EC3BD46; Wed, 25 Mar 2020 10:18:18 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69DB1A7EC for ; Wed, 25 Mar 2020 10:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585131532; 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=VIRj7R2wbbl+ArrhTmST/spZSVgNd6lOF/KyDrpg4A8=; b=h99EfHLNvEfmWpFumpHFUstMiuSkc3euTnIVhpaIqhmrfx6Aj/Fe/SvmkNDD/GGIwnkHWf N1pxdm9yF80qWA6zGQy9eUbp82d+xwQameoOdQ9vZ6NFw3nkHjW7VXuwVUbGjzAJ8+8qmW eK6mgTqgySMR/WOP6V05NqIFahgxqm8= X-MC-Unique: c5piV4axNkqMEN8RokDILQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/9] virDomainDriverGenerateMachineName: Factor out embed path hashing Date: Wed, 25 Mar 2020 11:18:03 +0100 Message-Id: <8b6d90edc49fe32e94fce6074e806aff3870ae5d.1585130420.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 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: Daniel Henrique Barboza --- 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..8c252f211b 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 * +virDomainDriverHashRoot(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 virDomainDriverHashRoot(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..6d07eeddd1 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -22,6 +22,10 @@ =20 #include "domain_conf.h" =20 +char * +virDomainDriverHashRoot(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..997904150d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1403,6 +1403,7 @@ virDomainCgroupSetupMemtune; =20 # hypervisor/domain_driver.h virDomainDriverGenerateMachineName; +virDomainDriverHashRoot; virDomainDriverMergeBlkioDevice; virDomainDriverParseBlkioDeviceStr; virDomainDriverSetupPersistentDefBlkioParams; --=20 2.24.1 From nobody Sat Feb 7 11:42:14 2026 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=1585131543; cv=none; d=zohomail.com; s=zohoarc; b=fjo643ujXhzy2U5Dj2mK/BdqzNjqK1gaWQhqiS3svGf65CtQ239azfJ4DAnwYQNKxL8r2UFiktj9NQ3/cw+sZamwQ8ON7TLXX9H6dsAEvx1k4i/w/C4iA9zQ8PQQZTzTsVUumiQ4yrp1Wx76i5r30HfAHssbIDHRijeaYY3/gqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585131543; 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=GPlRBjp2o5C5/6EJSoUjf7S89h3LYczkkNkF0Kv/ezw=; b=DZuZjUc7wM+YqTmE6OC1AUqKWeJ9vgfS6+Rstty5MOyYXF2md0iaLzi0GYueTY4Pgk/pF7qfb3SpfOSyfQMx2aNCBHmP7obKz8CQytG7kpEyk0Vgw1UAX9BeYiyVG6Q3CJbdOUve1vQ18Porvo2lo+PbF0VdvMLFFGJmaDYAEcM= 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 1585131543917145.59699513136002; Wed, 25 Mar 2020 03:19:03 -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-414-3ftM1VwrNzC3X0-QcsmOoA-1; Wed, 25 Mar 2020 06:18:50 -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 D6D528017DF; Wed, 25 Mar 2020 10:18:44 +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 AE26D5C28E; Wed, 25 Mar 2020 10:18:44 +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 6108B18089CE; Wed, 25 Mar 2020 10:18:44 +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 02PAIJOg000375 for ; Wed, 25 Mar 2020 06:18:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id CCCC2A7EC; Wed, 25 Mar 2020 10:18:19 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B4A5194BB for ; Wed, 25 Mar 2020 10:18:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585131542; 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=GPlRBjp2o5C5/6EJSoUjf7S89h3LYczkkNkF0Kv/ezw=; b=ANMavEyVb4khRgilu74noWCfeWf39YWI2sW+f4poaM8SdDzfEjikBLGYyfXwLmUrrGyAoT wa8iNNN2vKXJuOj7thsYm24lssrN/gElwCJOpZO5YP/fWTXFQvciajvT/tf/84KEz4JWi0 LmqXUiZL2bfELkd9zpJyW3zvIpy5OVA= X-MC-Unique: 3ftM1VwrNzC3X0-QcsmOoA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/9] qemu: Introduce virQEMUDriverGetEmbedRoot Date: Wed, 25 Mar 2020 11:18:04 +0100 Message-Id: <2cba5c86b23ae7a7bf002cb4562a0540488f539c.1585130420.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" 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 15837cece4..fb7c5a1a8a 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 14f9b9e81e..77e984ccdc 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 Sat Feb 7 11:42:14 2026 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=1585131541; cv=none; d=zohomail.com; s=zohoarc; b=MqbW17nvPvs/2+WfClwBN/ese06vO/R1/RFIvRtIgzWKH5nAXur4DFIu2Ud7/eJZg0Twga7fl6hTJ2SVE6oqidKkm+MW27QhgS0J274kJZ4kraDV2yOxQW8XR2/zo6Iob4hCwJ6bUPWp4VjLAUm/n8QpLLQOIJtAVPIS/rUCCgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585131541; 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=4b9R0WliZZpjo9Zx9c3N5sEfiK+1lW7/TCxbJeSGb1g=; b=cyOe5RX+bCyaZJWc4CvRUphAb5GUBFx2t+Kxy2+Y3ukYS80fPS3wa8lV1mkmL+6BE0DrBwbpE01JrMgFNe8IGlpAza+nvxGjOn/tEQniOoj3IBrOgdgTFceG9UObQkRSSO0YTKQHAs1JtmBsbN+kKXJN9wDvNCIG6UDQH5osuxQ= 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 1585131541910808.5111540239667; Wed, 25 Mar 2020 03:19:01 -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-318-Ov7r-E_dN3mBEtFYiyFigQ-1; Wed, 25 Mar 2020 06:18:57 -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 A1AEC8014CC; Wed, 25 Mar 2020 10:18: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 75CCE5C28E; Wed, 25 Mar 2020 10:18: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 26B44944C5; Wed, 25 Mar 2020 10:18:49 +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 02PAIKIQ000386 for ; Wed, 25 Mar 2020 06:18:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id B0968A7EC; Wed, 25 Mar 2020 10:18:20 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D541194BB for ; Wed, 25 Mar 2020 10:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585131540; 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=4b9R0WliZZpjo9Zx9c3N5sEfiK+1lW7/TCxbJeSGb1g=; b=TEGug76CydZNmnqoYhuKxcG496W7PNWCDAfn+t0uEGri+zMKh+9U9NYsUE/77g6ylUyntV DoxMRlMKn9wNS/ci2j2YLGzNB85AoKu+abW1L59RDz/ZEEdMV39NbMN0u1/OG6pRIJZbm5 AYeBdirJV1GLZ+ct+nY78LR3Uy4tx0c= X-MC-Unique: Ov7r-E_dN3mBEtFYiyFigQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/9] qemuDomainGetMachineName: Access embeddedRoot from driver rather than cfg Date: Wed, 25 Mar 2020 11:18:05 +0100 Message-Id: <807803febb78e22dea3cf8bce511e1f5ad50a909.1585130420.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 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 b921126e1c..e0a2f3c695 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -16481,7 +16481,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) { @@ -16491,7 +16490,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 Sat Feb 7 11:42:14 2026 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=1585131538; cv=none; d=zohomail.com; s=zohoarc; b=kYZyVQk4flOGHbhL2CijZYy8GgSFq4ibaGZG72Hh5cEBaDQoNh7fO3jMV/MCMr9krbAimAgP/OB8rxcb/u9R7peV3Jl9NWI3Dp8r30PUD8NKGmSQ5X9EDzFVxeFczkABJVAbKZpnb7j2F1Tz0b8wCdiuWjpuAgtTsIKEvwgHAoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585131538; 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=Sd/bjz/DTkIoUJiAOdXn2nAnsJR7EYRO/mLDutEWBuA=; b=ED7KPWiD0y+Vjf+4QugKPR4i3vNaZnajf8x9DLo+Kq4KmGII5QqRV1ds572dH9Y6M2t4tXugtKNvsHbbGX0lpxUbtgg5m9ZWJE/ZfTHePud4d1QrD2QNkP81gSWh12RGHN/TDjjxqFFb+pnVZDliufvlnaH3Q9BAivA02gim+AY= 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 1585131538220561.0055946828385; Wed, 25 Mar 2020 03:18:58 -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-78-VxLGPT1EMHaLmDoqX4-1HA-1; Wed, 25 Mar 2020 06:18:54 -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 554B48014CD; Wed, 25 Mar 2020 10:18:49 +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 2BA7C1000322; Wed, 25 Mar 2020 10:18: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 D5A5E18089D7; Wed, 25 Mar 2020 10:18: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 02PAILiT000392 for ; Wed, 25 Mar 2020 06:18:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 92B62A7EC; Wed, 25 Mar 2020 10:18:21 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 116B6194BB for ; Wed, 25 Mar 2020 10:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585131536; 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=Sd/bjz/DTkIoUJiAOdXn2nAnsJR7EYRO/mLDutEWBuA=; b=bOGH3WsFk25al98uaE1EchHf0NW4YH+QtNTet6nzu/bjyhC6MnW6ElMWFFi+hIYtKNh2nz 60m5FQCQ+tbQI0iKcnkfur+zdjqQXHvc6BcSd0JQYq+mOq000dBvBc3qEi8r0iE17NBLxz V8XyqPHQMTA79aumbzV/PlZ0zL+ffNs= X-MC-Unique: VxLGPT1EMHaLmDoqX4-1HA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 6/9] Revert "qemu_conf: Track embed root dir" Date: Wed, 25 Mar 2020 11:18:06 +0100 Message-Id: <962e57eb8ecba665b680df679e4be08061c03687.1585130420.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.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" 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 --- 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 fb7c5a1a8a..6eb655fe21 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 77e984ccdc..0f0eb60c69 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 Sat Feb 7 11:42:14 2026 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=1585131547; cv=none; d=zohomail.com; s=zohoarc; b=PFOPtLHGj4QysPD7STRjKys8SPxYm2u6cOPnTHeSvZ/liBLWgBNfkHEht+OtdcKGyF6McSsywSr8+/tsx1US3kJaKG6+OAAy6tb+DqqOu315x096Vnf29IassUL2u9f8fFdWBuReEwVQAKTzPTTojItzTW9kFaMfAO+9nQ1KwU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585131547; 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=l1g1xYJm8R08Cg9PV1dTyWMqgSziEMpUPgQmIc5cm9U=; b=iI/g3QXfckn6cwmhc6DP2F0Ei+YCBAtAKLYGcX4UUlGIxtyZDfgfbwzCAWRiQcOUHS8J3eygK4XL5G4tw+/BYZknrIPJSvJcL7nzqtwM4Q0kH/kb68H/9P1CgLwcLAisU1cSg+4YhfRhmRzCrOhIKfUh/49Zqgu/NZjIQWlVBEc= 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 1585131547214191.79667233952125; Wed, 25 Mar 2020 03:19:07 -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-474-FgIJBiZENnKGT1qQ2r6V6A-1; Wed, 25 Mar 2020 06:19:03 -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 15400149C5; Wed, 25 Mar 2020 10:18:58 +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 D5C9860BF3; Wed, 25 Mar 2020 10:18:57 +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 8E61018089D7; Wed, 25 Mar 2020 10:18:57 +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 02PAIMiT000404 for ; Wed, 25 Mar 2020 06:18:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 73D8E46; Wed, 25 Mar 2020 10:18:22 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6FD4194BB for ; Wed, 25 Mar 2020 10:18:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585131545; 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=l1g1xYJm8R08Cg9PV1dTyWMqgSziEMpUPgQmIc5cm9U=; b=fiu1dh9BVrJXsjMckK4X+XI4QcAqEHLOIKauvdqdZtu7ifIJpBECR2Bws0uzWzCJzun7rW NuEzeWugek7ws9QYCK1+82YZ70empVG6Sacv+NnNCXXK3VyCgm9Uv6c6VrvyB8qyMr90vQ sf8bstqyFyekP5UjvaEBET8HUpaF0uE= X-MC-Unique: FgIJBiZENnKGT1qQ2r6V6A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 7/9] qemu: Make hugepages path generation embed driver aware Date: Wed, 25 Mar 2020 11:18:07 +0100 Message-Id: <1fd816b75192e70c022917338cf0b69b8580cc63.1585130420.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" 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 --- 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 3a772fa3f3..6c21d28510 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; @@ -7249,7 +7249,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 6eb655fe21..f2e3111312 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) { + g_autofree char * hash =3D virDomainDriverHashRoot(QEMU_DRIVER_NAM= E, 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 0f0eb60c69..9b282db372 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 209f8279bd..ac866a923d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -918,7 +918,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 fcb47e8596..7035c6d426 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 Sat Feb 7 11:42:14 2026 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=1585131541; cv=none; d=zohomail.com; s=zohoarc; b=TrWhWFDgRpvgjt/mjOSFxkajSLwFUZ56zjR1udJqN698KTcPVYuzRM1npysRq/DehbGV78BrLKPEBlwNMgIXCC5V4eMTBjDOla6RoOO/MtJJpF7GGlmu2HJWvxhJM8fuNYvQBGivyxuE2+25LjTtzL3KbWi6rke2fk2qCmu/6sE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585131541; 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=RNWdhDF7xytiMcgqxmCzIsnm5AL3sicNlyxQbBxOERg=; b=U+dAWCWm3EqLgjMwLMbf70FNNLWApn2d2zeouiNwe+W9EveeDeCnyal3kyTILirbuxr9h8VGyBOkr5ubyZAQeuSXIXrK7cTtNPHBs8SgM1Gsasu7EFzE4t+xGMACSwxo76zFcyRsl+d274XhQPD71BvJYCdcziDxUlyHjlfgJoc= 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 1585131541849817.8243225000934; Wed, 25 Mar 2020 03:19:01 -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-47-V0M7ubjLMQeD2K7SUKrCGg-1; Wed, 25 Mar 2020 06:18:58 -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 0D5AE149C7; Wed, 25 Mar 2020 10:18: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 DC06A1000322; Wed, 25 Mar 2020 10:18:52 +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 98D6918089D6; Wed, 25 Mar 2020 10:18:52 +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 02PAINan000415 for ; Wed, 25 Mar 2020 06:18:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5559D46; Wed, 25 Mar 2020 10:18:23 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7FB8194BB for ; Wed, 25 Mar 2020 10:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585131540; 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=RNWdhDF7xytiMcgqxmCzIsnm5AL3sicNlyxQbBxOERg=; b=GIP7TstiSzBP4n7LTace8llXJyk3ar1+Jfx/9s9xzGomQKkYOtNoeAp+LEU4nLw2wbKR9+ 44h2aB7wHdVyDXpumTI8NhU/OBAYb2uzhRKdpxrNQRnAg7+vB9drxiEEPvYKJWWNSKi4n5 eL7o1e50AJF3frnbyI/CDfCLSf9dmsE= X-MC-Unique: V0M7ubjLMQeD2K7SUKrCGg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 8/9] qemu: Make memory path generation embed driver aware Date: Wed, 25 Mar 2020 11:18:08 +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" So far, libvirt generates the following path for memory: $memoryBackingDir/libvirt/qemu/$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/libvirt/qemu/1-QEMUGuest/ram-node0 While in case of embed driver the following path would be generated by default: $root/lib/qemu/ram/libvirt/qemu/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 --- src/qemu/qemu_command.c | 15 +++++++-------- src/qemu/qemu_conf.c | 26 +++++++++++++++++--------- src/qemu/qemu_conf.h | 10 +++++----- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 5 ++--- 5 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6c21d28510..773b93740f 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 @@ -7231,11 +7231,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 @@ -7252,7 +7252,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; @@ -7271,7 +7271,6 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg, =20 static int qemuBuildMemCommandLine(virCommandPtr cmd, - virQEMUDriverConfigPtr cfg, const virDomainDef *def, virQEMUCapsPtr qemuCaps, qemuDomainObjPrivatePtr priv) @@ -7303,7 +7302,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)) { @@ -7384,7 +7383,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++) { @@ -9877,7 +9876,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 f2e3111312..b48d5ab3fd 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1972,16 +1972,24 @@ qemuGetDomainHupageMemPath(virQEMUDriverPtr driver, =20 =20 void -qemuGetMemoryBackingBasePath(virQEMUDriverConfigPtr cfg, +qemuGetMemoryBackingBasePath(virQEMUDriverPtr driver, char **path) { - *path =3D g_strdup_printf("%s/libvirt/qemu", cfg->memoryBackingDir); + const char *root =3D virQEMUDriverGetEmbedRoot(driver); + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + + if (root) { + g_autofree char * hash =3D virDomainDriverHashRoot(QEMU_DRIVER_NAM= E, root); + *path =3D g_strdup_printf("%s/libvirt/%s", cfg->memoryBackingDir, = hash); + } else { + *path =3D g_strdup_printf("%s/libvirt/qemu", cfg->memoryBackingDir= ); + } } =20 =20 int -qemuGetMemoryBackingDomainPath(const virDomainDef *def, - virQEMUDriverConfigPtr cfg, +qemuGetMemoryBackingDomainPath(virQEMUDriverPtr driver, + const virDomainDef *def, char **path) { g_autofree char *shortName =3D NULL; @@ -1990,7 +1998,7 @@ qemuGetMemoryBackingDomainPath(const virDomainDef *de= f, if (!(shortName =3D virDomainDefGetShortName(def))) return -1; =20 - qemuGetMemoryBackingBasePath(cfg, &base); + qemuGetMemoryBackingBasePath(driver, &base); *path =3D g_strdup_printf("%s/%s", base, shortName); =20 return 0; @@ -1999,8 +2007,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 * @@ -2010,8 +2018,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) { @@ -2024,7 +2032,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 9b282db372..3ac2b149fd 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -399,12 +399,12 @@ int qemuGetDomainHupageMemPath(virQEMUDriverPtr drive= r, unsigned long long pagesize, char **memPath); =20 -void qemuGetMemoryBackingBasePath(virQEMUDriverConfigPtr cfg, +void qemuGetMemoryBackingBasePath(virQEMUDriverPtr driver, char **path); -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_driver.c b/src/qemu/qemu_driver.c index ac866a923d..2971d54772 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -935,7 +935,7 @@ qemuStateInitialize(bool privileged, goto error; } =20 - qemuGetMemoryBackingBasePath(cfg, &memoryBackingPath); + qemuGetMemoryBackingBasePath(qemu_driver, &memoryBackingPath); =20 if (virFileMakePath(memoryBackingPath) < 0) { virReportSystemError(errno, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7035c6d426..8384b4a136 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 Sat Feb 7 11:42:14 2026 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=1585131531; cv=none; d=zohomail.com; s=zohoarc; b=QYcMV0P01jcBAG46mZ99zJfz2jh5W5nhXJVgVmZJG72RbMp9qXlBhala4SdYh6x/oK72Yrtj/sfkxU0e18LerCG+R3KXxxXYef318kRnzyIMG6EcTWX5V2deZxNzWyPRcit54EgmXGVDwur4qnJ3oPLjwqxVZrNAWCn1ZOCKRGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585131531; 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=NJRKHXNLQpSq0Qa7uRF7zVMyxMy1N4ENlFUsqgxCvfE=; b=LZNsOBKo/U++FoE53GSJskGCJJ/30nO9TqVSlm1/jht+lMDDPvkyAJLMqcFF8GIFu6FAoM8/xobr2eJSqiwtpqRYKL27Aq9AOnDm9MW+Wfk7xSkY9ltEUAnFWL6gg0Q5XYaOr04iaX5W0cTLXVI9NTKGt/ckzlZ0I7Bp3GY+iLM= 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 158513153189529.50345554972057; Wed, 25 Mar 2020 03:18: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-307-zjrDHhQMP3CSGudAmvrRAQ-1; Wed, 25 Mar 2020 06:18:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5B371005509; Wed, 25 Mar 2020 10:18: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 9D66F92F80; Wed, 25 Mar 2020 10:18: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 5A8861809567; Wed, 25 Mar 2020 10:18:42 +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 02PAIOLT000427 for ; Wed, 25 Mar 2020 06:18:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 37549385; Wed, 25 Mar 2020 10:18:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA22A194BB for ; Wed, 25 Mar 2020 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585131530; 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=NJRKHXNLQpSq0Qa7uRF7zVMyxMy1N4ENlFUsqgxCvfE=; b=Z/FtggMhlG7ShWXpw5HF+oXrnpaPkwCUTUl6l9fytUhK9JME3Kz8Y58yPBq2C7Ek5Wwzrr m/79Nf+wJn4lp1SSGzWwxXj7NmWyL+EN9EUMt+ZXbPO7dnNXv+kP2Ph2aIRnRFSwauWmBK mCCCwwD957yPosSKwmOH0TEIgSiF2So= X-MC-Unique: zjrDHhQMP3CSGudAmvrRAQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 9/9] qemu: Make auto dump path generation embed driver aware Date: Wed, 25 Mar 2020 11:18: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.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 --- 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 2971d54772..def2732189 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4114,6 +4114,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; @@ -4126,6 +4127,11 @@ getAutoDumpPath(virQEMUDriverPtr driver, =20 nowstr =3D g_date_time_format(now, "%Y-%m-%d-%H:%M:%S"); =20 + if (root) { + g_autofree char * hash =3D virDomainDriverHashRoot(QEMU_DRIVER_NAM= E, 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