This is required in case a lock manager needs to contact libvirtd in case of an unexpected event. --- docs/internals/locking.html.in | 8 ++++++++ src/locking/domain_lock.c | 25 +++++++++++++++++-------- src/locking/domain_lock.h | 4 ++++ src/locking/lock_driver.h | 1 + src/qemu/qemu_driver.c | 3 ++- src/qemu/qemu_hotplug.c | 15 ++++++++++----- src/qemu/qemu_process.c | 4 +++- 7 files changed, 45 insertions(+), 15 deletions(-) diff --git a/docs/internals/locking.html.in b/docs/internals/locking.html.in index e84321b..b43fe7a 100644 --- a/docs/internals/locking.html.in +++ b/docs/internals/locking.html.in @@ -183,6 +183,10 @@ .key = "pid", .value = { .i = dom->pid }, }, + { .type = VIR_LOCK_MANAGER_PARAM_TYPE_CSTRING, + .key = "driver", + .value = { .cstr = driver->name }, + }, }; mgr = virLockManagerNew(lockPlugin, VIR_LOCK_MANAGER_TYPE_DOMAIN, @@ -225,6 +229,10 @@ .key = "pid", .value = { .i = dom->pid }, }, + { .type = VIR_LOCK_MANAGER_PARAM_TYPE_CSTRING, + .key = "driver", + .value = { .cstr = driver->name }, + }, }; mgr = virLockManagerNew(lockPlugin, VIR_LOCK_MANAGER_TYPE_DOMAIN, diff --git a/src/locking/domain_lock.c b/src/locking/domain_lock.c index 3417361..999b9a0 100644 --- a/src/locking/domain_lock.c +++ b/src/locking/domain_lock.c @@ -97,6 +97,7 @@ static int virDomainLockManagerAddDisk(virLockManagerPtr lock, } static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin, + const char *driver, virDomainObjPtr dom, bool withResources) { @@ -118,6 +119,10 @@ static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr plugin, .key = "pid", .value = { .i = dom->pid }, }, + { .type = VIR_LOCK_MANAGER_PARAM_TYPE_CSTRING, + .key = "driver", + .value = { .cstr = driver }, + }, }; VIR_DEBUG("plugin=%p dom=%p withResources=%d", plugin, dom, withResources); @@ -152,6 +157,7 @@ error: int virDomainLockProcessStart(virLockManagerPluginPtr plugin, + const char *driver, virDomainObjPtr dom, bool paused, int *fd) @@ -163,7 +169,7 @@ int virDomainLockProcessStart(virLockManagerPluginPtr plugin, VIR_DEBUG("plugin=%p dom=%p paused=%d fd=%p", plugin, dom, paused, fd); - if (!(lock = virDomainLockManagerNew(plugin, dom, true))) + if (!(lock = virDomainLockManagerNew(plugin, driver, dom, true))) return -1; if (paused) @@ -186,7 +192,7 @@ int virDomainLockProcessPause(virLockManagerPluginPtr plugin, VIR_DEBUG("plugin=%p dom=%p state=%p", plugin, dom, state); - if (!(lock = virDomainLockManagerNew(plugin, dom, true))) + if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, true))) return -1; ret = virLockManagerRelease(lock, state, 0); @@ -196,6 +202,7 @@ int virDomainLockProcessPause(virLockManagerPluginPtr plugin, } int virDomainLockProcessResume(virLockManagerPluginPtr plugin, + const char *driver, virDomainObjPtr dom, const char *state) { @@ -205,7 +212,7 @@ int virDomainLockProcessResume(virLockManagerPluginPtr plugin, VIR_DEBUG("plugin=%p dom=%p state=%s", plugin, dom, NULLSTR(state)); - if (!(lock = virDomainLockManagerNew(plugin, dom, true))) + if (!(lock = virDomainLockManagerNew(plugin, driver, dom, true))) return -1; ret = virLockManagerAcquire(lock, state, 0, NULL); @@ -224,7 +231,7 @@ int virDomainLockProcessInquire(virLockManagerPluginPtr plugin, VIR_DEBUG("plugin=%p dom=%p state=%p", plugin, dom, state); - if (!(lock = virDomainLockManagerNew(plugin, dom, true))) + if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, true))) return -1; ret = virLockManagerInquire(lock, state, 0); @@ -235,6 +242,7 @@ int virDomainLockProcessInquire(virLockManagerPluginPtr plugin, int virDomainLockDiskAttach(virLockManagerPluginPtr plugin, + const char *driver, virDomainObjPtr dom, virDomainDiskDefPtr disk) { @@ -244,7 +252,7 @@ int virDomainLockDiskAttach(virLockManagerPluginPtr plugin, VIR_DEBUG("plugin=%p dom=%p disk=%p", plugin, dom, disk); - if (!(lock = virDomainLockManagerNew(plugin, dom, false))) + if (!(lock = virDomainLockManagerNew(plugin, driver, dom, false))) return -1; if (virDomainLockManagerAddDisk(lock, disk) < 0) @@ -271,7 +279,7 @@ int virDomainLockDiskDetach(virLockManagerPluginPtr plugin, VIR_DEBUG("plugin=%p dom=%p disk=%p", plugin, dom, disk); - if (!(lock = virDomainLockManagerNew(plugin, dom, false))) + if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, false))) return -1; if (virDomainLockManagerAddDisk(lock, disk) < 0) @@ -290,6 +298,7 @@ cleanup: int virDomainLockLeaseAttach(virLockManagerPluginPtr plugin, + const char *driver, virDomainObjPtr dom, virDomainLeaseDefPtr lease) { @@ -299,7 +308,7 @@ int virDomainLockLeaseAttach(virLockManagerPluginPtr plugin, VIR_DEBUG("plugin=%p dom=%p lease=%p", plugin, dom, lease); - if (!(lock = virDomainLockManagerNew(plugin, dom, false))) + if (!(lock = virDomainLockManagerNew(plugin, driver, dom, false))) return -1; if (virDomainLockManagerAddLease(lock, lease) < 0) @@ -326,7 +335,7 @@ int virDomainLockLeaseDetach(virLockManagerPluginPtr plugin, VIR_DEBUG("plugin=%p dom=%p lease=%p", plugin, dom, lease); - if (!(lock = virDomainLockManagerNew(plugin, dom, false))) + if (!(lock = virDomainLockManagerNew(plugin, NULL, dom, false))) return -1; if (virDomainLockManagerAddLease(lock, lease) < 0) diff --git a/src/locking/domain_lock.h b/src/locking/domain_lock.h index 3bedeb1..42f80a2 100644 --- a/src/locking/domain_lock.h +++ b/src/locking/domain_lock.h @@ -27,6 +27,7 @@ # include "lock_manager.h" int virDomainLockProcessStart(virLockManagerPluginPtr plugin, + const char *driver, virDomainObjPtr dom, bool paused, int *fd); @@ -34,6 +35,7 @@ int virDomainLockProcessPause(virLockManagerPluginPtr plugin, virDomainObjPtr dom, char **state); int virDomainLockProcessResume(virLockManagerPluginPtr plugin, + const char *driver, virDomainObjPtr dom, const char *state); int virDomainLockProcessInquire(virLockManagerPluginPtr plugin, @@ -41,6 +43,7 @@ int virDomainLockProcessInquire(virLockManagerPluginPtr plugin, char **state); int virDomainLockDiskAttach(virLockManagerPluginPtr plugin, + const char *driver, virDomainObjPtr dom, virDomainDiskDefPtr disk); int virDomainLockDiskDetach(virLockManagerPluginPtr plugin, @@ -48,6 +51,7 @@ int virDomainLockDiskDetach(virLockManagerPluginPtr plugin, virDomainDiskDefPtr disk); int virDomainLockLeaseAttach(virLockManagerPluginPtr plugin, + const char *driver, virDomainObjPtr dom, virDomainLeaseDefPtr lease); int virDomainLockLeaseDetach(virLockManagerPluginPtr plugin, diff --git a/src/locking/lock_driver.h b/src/locking/lock_driver.h index c33aea7..988a71a 100644 --- a/src/locking/lock_driver.h +++ b/src/locking/lock_driver.h @@ -155,6 +155,7 @@ typedef int (*virLockDriverDeinit)(void); * - uuid: the domain uuid (uuid) * - name: the domain name (string) * - pid: process ID to own/owning the lock (unsigned int) + * - driver: the name of the libvirtd driver the domain belongs to (string) * * Returns 0 if successful initialized a new context, -1 on error */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e1be849..9b0e6b3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10692,7 +10692,8 @@ qemuDomainSnapshotCreateSingleDiskActive(struct qemud_driver *driver, origdriver = disk->driverType; disk->driverType = (char *) "raw"; /* Don't want to probe backing files */ - if (virDomainLockDiskAttach(driver->lockManager, vm, disk) < 0) + if (virDomainLockDiskAttach(driver->lockManager, QEMU_URI_SCHEME, + vm, disk) < 0) goto cleanup; if (cgroup && qemuSetupDiskCgroup(driver, vm, cgroup, disk) < 0) { if (virDomainLockDiskDetach(driver->lockManager, vm, disk) < 0) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index a738b19..87a3cc4 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -88,7 +88,8 @@ int qemuDomainChangeEjectableMedia(struct qemud_driver *driver, return -1; } - if (virDomainLockDiskAttach(driver->lockManager, vm, disk) < 0) + if (virDomainLockDiskAttach(driver->lockManager, QEMU_URI_SCHEME, + vm, disk) < 0) return -1; if (virSecurityManagerSetImageLabel(driver->securityManager, @@ -217,7 +218,8 @@ int qemuDomainAttachPciDiskDevice(virConnectPtr conn, } } - if (virDomainLockDiskAttach(driver->lockManager, vm, disk) < 0) + if (virDomainLockDiskAttach(driver->lockManager, QEMU_URI_SCHEME, + vm, disk) < 0) return -1; if (virSecurityManagerSetImageLabel(driver->securityManager, @@ -449,7 +451,8 @@ int qemuDomainAttachSCSIDisk(virConnectPtr conn, } } - if (virDomainLockDiskAttach(driver->lockManager, vm, disk) < 0) + if (virDomainLockDiskAttach(driver->lockManager, QEMU_URI_SCHEME, + vm, disk) < 0) return -1; if (virSecurityManagerSetImageLabel(driver->securityManager, @@ -572,7 +575,8 @@ int qemuDomainAttachUsbMassstorageDevice(virConnectPtr conn, } } - if (virDomainLockDiskAttach(driver->lockManager, vm, disk) < 0) + if (virDomainLockDiskAttach(driver->lockManager, QEMU_URI_SCHEME, + vm, disk) < 0) return -1; if (virSecurityManagerSetImageLabel(driver->securityManager, @@ -2389,7 +2393,8 @@ int qemuDomainAttachLease(struct qemud_driver *driver, if (virDomainLeaseInsertPreAlloc(vm->def) < 0) return -1; - if (virDomainLockLeaseAttach(driver->lockManager, vm, lease) < 0) { + if (virDomainLockLeaseAttach(driver->lockManager, QEMU_URI_SCHEME, + vm, lease) < 0) { virDomainLeaseInsertPreAlloced(vm->def, NULL); return -1; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 31909b7..de35714 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2597,6 +2597,7 @@ static int qemuProcessHook(void *data) if (virSecurityManagerSetSocketLabel(h->driver->securityManager, h->vm->def) < 0) goto cleanup; if (virDomainLockProcessStart(h->driver->lockManager, + QEMU_URI_SCHEME, h->vm, /* QEMU is always pased initially */ true, @@ -2666,7 +2667,8 @@ qemuProcessStartCPUs(struct qemud_driver *driver, virDomainObjPtr vm, qemuDomainObjPrivatePtr priv = vm->privateData; VIR_DEBUG("Using lock state '%s'", NULLSTR(priv->lockState)); - if (virDomainLockProcessResume(driver->lockManager, vm, priv->lockState) < 0) { + if (virDomainLockProcessResume(driver->lockManager, QEMU_URI_SCHEME, + vm, priv->lockState) < 0) { /* Don't free priv->lockState on error, because we need * to make sure we have state still present if the user * tries to resume again -- 1.7.12 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list