src/libxl/libxl_driver.c | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
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=1732306
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
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;
}
+static int
+libxlDomainSetMetadata(virDomainPtr dom,
+ int type,
+ const char *metadata,
+ const char *key,
+ const char *uri,
+ unsigned int flags)
+{
+ libxlDriverPrivatePtr driver = dom->conn->privateData;
+ VIR_AUTOUNREF(libxlDriverConfigPtr) cfg = libxlDriverConfigGet(driver);
+ virDomainObjPtr vm = NULL;
+ int ret = -1;
+
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG, -1);
+
+ if (!(vm = 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 = virDomainObjSetMetadata(vm, type, metadata, key, uri, cfg->caps,
+ driver->xmlopt, cfg->stateDir,
+ cfg->configDir, flags);
+
+ if (ret == 0) {
+ virObjectEventPtr ev = NULL;
+ ev = 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 = NULL;
+
+ if (!(vm = libxlDomObjFromDomain(dom)))
+ return NULL;
+
+ if (virDomainGetMetadataEnsureACL(dom->conn, vm->def) < 0)
+ goto cleanup;
+
+ ret = virDomainObjGetMetadata(vm, type, uri, flags);
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
static virHypervisorDriver libxlHypervisorDriver = {
.name = LIBXL_DRIVER_NAME,
.connectURIProbe = libxlConnectURIProbe,
@@ -6628,6 +6692,9 @@ static virHypervisorDriver libxlHypervisorDriver = {
.connectGetDomainCapabilities = libxlConnectGetDomainCapabilities, /* 2.0.0 */
.connectCompareCPU = libxlConnectCompareCPU, /* 2.3.0 */
.connectBaselineCPU = libxlConnectBaselineCPU, /* 2.3.0 */
+ .domainSetMetadata = libxlDomainSetMetadata, /* 5.7.0 */
+ .domainGetMetadata = libxlDomainGetMetadata, /* 5.7.0 */
+
};
static virConnectDriver libxlConnectDriver = {
--
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Mon, Aug 05, 2019 at 10:53:33AM +0200, Michal Privoznik wrote: > 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=1732306 > > Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com> -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2024 Red Hat, Inc.