From nobody Tue Nov 26 19:52:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564995328; cv=none; d=zoho.com; s=zohoarc; b=Yb8/usVSpI1+zDbWDxypgC8PKtjDIi76h2prD+kPV42S9iyW89h1gt1vgr57wmPhqTRVycWqkP4low2bzEsno1A7t4GkmxqgYAB7vw/TznLPiJSAsMl/s+FxdU+7nG/tMsaLTo1c5msNO/BMi0BAD463vLKAHku2hjYVVYL7JLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564995328; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=McNXg1oZIORkU8QnRk8Ih+TX/h1u3knVvkkYGX002Kg=; b=nDNb7ku7nyiJv5AoTkTcBsgGgxCzxAIMNdbD7hkX78WxfOdFc97ejIjpA1sQnqAcScga52zkxY8Er6mHlWPqUsRmtyXEvJNGYHwOrOijosGTBJ5fMsAuiWiHqNG1JiZrseMQZYmJC0J7rqQqjpSaiKFmfCdVU35s499W9SXB87I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564995328415892.6444789081983; Mon, 5 Aug 2019 01:55:28 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 4CA323082115; Mon, 5 Aug 2019 08:55: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 672A1194B2; Mon, 5 Aug 2019 08:55:21 +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 0B8964E58B; Mon, 5 Aug 2019 08:55:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x758rn8p011940 for ; Mon, 5 Aug 2019 04:53:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 705D71000323; Mon, 5 Aug 2019 08:53:49 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-137.brq.redhat.com [10.40.204.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id E33DC1000321 for ; Mon, 5 Aug 2019 08:53:46 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 5 Aug 2019 10:53:33 +0200 Message-Id: <46edf7b92c3e32733c4ee20fab6c07f25b6eacc3.1564995213.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] libxl: Implement domain metadata getter/setter 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 05 Aug 2019 08:55:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Fortunately, the code that handles metadata getting or setting is driver agnostic, so all that is needed from individual hypervisor drivers is to call the right functions. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1732306 Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/libxl/libxl_driver.c | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 492028c487..ca01f620c7 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -6515,6 +6515,70 @@ libxlConnectBaselineCPU(virConnectPtr conn, return cpustr; } =20 +static int +libxlDomainSetMetadata(virDomainPtr dom, + int type, + const char *metadata, + const char *key, + const char *uri, + unsigned int flags) +{ + libxlDriverPrivatePtr driver =3D dom->conn->privateData; + VIR_AUTOUNREF(libxlDriverConfigPtr) cfg =3D libxlDriverConfigGet(drive= r); + virDomainObjPtr vm =3D NULL; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!(vm =3D libxlDomObjFromDomain(dom))) + return -1; + + if (virDomainSetMetadataEnsureACL(dom->conn, vm->def, flags) < 0) + goto cleanup; + + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto cleanup; + + ret =3D virDomainObjSetMetadata(vm, type, metadata, key, uri, cfg->cap= s, + driver->xmlopt, cfg->stateDir, + cfg->configDir, flags); + + if (ret =3D=3D 0) { + virObjectEventPtr ev =3D NULL; + ev =3D virDomainEventMetadataChangeNewFromObj(vm, type, uri); + virObjectEventStateQueue(driver->domainEventState, ev); + } + + libxlDomainObjEndJob(driver, vm); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + +static char * +libxlDomainGetMetadata(virDomainPtr dom, + int type, + const char *uri, + unsigned int flags) +{ + virDomainObjPtr vm; + char *ret =3D NULL; + + if (!(vm =3D libxlDomObjFromDomain(dom))) + return NULL; + + if (virDomainGetMetadataEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + ret =3D virDomainObjGetMetadata(vm, type, uri, flags); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + static virHypervisorDriver libxlHypervisorDriver =3D { .name =3D LIBXL_DRIVER_NAME, .connectURIProbe =3D libxlConnectURIProbe, @@ -6628,6 +6692,9 @@ static virHypervisorDriver libxlHypervisorDriver =3D { .connectGetDomainCapabilities =3D libxlConnectGetDomainCapabilities, /= * 2.0.0 */ .connectCompareCPU =3D libxlConnectCompareCPU, /* 2.3.0 */ .connectBaselineCPU =3D libxlConnectBaselineCPU, /* 2.3.0 */ + .domainSetMetadata =3D libxlDomainSetMetadata, /* 5.7.0 */ + .domainGetMetadata =3D libxlDomainGetMetadata, /* 5.7.0 */ + }; =20 static virConnectDriver libxlConnectDriver =3D { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list