As this is on yet unreleased API this change is possible.
This patch changes devAlias parameter in event callback to
disk target as mgmt application is more likely to know target
(it's required on domain definition) but aliases are generated
by the daemon. So we can say this spares mgmt application at least
one subsequent call of dumpxml on incoming event.
---
daemon/remote.c | 6 +++---
examples/domain-events/events-c/event-test.c | 6 +++---
examples/domain-events/events-python/event-test.py | 6 +++---
include/libvirt/libvirt.h.in | 3 ++-
python/libvirt-override-virConnect.py | 4 ++--
python/libvirt-override.c | 4 ++--
src/conf/domain_event.c | 18 +++++++++---------
src/conf/domain_event.h | 4 ++--
src/qemu/qemu_domain.c | 2 +-
src/remote/remote_driver.c | 2 +-
src/remote/remote_protocol.x | 2 +-
src/remote_protocol-structs | 2 +-
12 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 9d70163..c1441d1 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -455,7 +455,7 @@ static int remoteRelayDomainEventDiskChange(virConnectPtr conn
ATTRIBUTE_UNUSED,
virDomainPtr dom,
const char *oldSrcPath,
const char *newSrcPath,
- const char *devAlias,
+ const char *target,
int reason,
void *opaque)
{
@@ -467,7 +467,7 @@ static int remoteRelayDomainEventDiskChange(virConnectPtr conn
ATTRIBUTE_UNUSED,
return -1;
VIR_DEBUG("Relaying domain %s %d disk change %s %s %s %d",
- dom->name, dom->id, oldSrcPath, newSrcPath, devAlias, reason);
+ dom->name, dom->id, oldSrcPath, newSrcPath, target, reason);
/* build return data */
memset(&data, 0, sizeof data);
@@ -483,7 +483,7 @@ static int remoteRelayDomainEventDiskChange(virConnectPtr conn
ATTRIBUTE_UNUSED,
data.oldSrcPath = oldSrcPath_p;
data.newSrcPath = newSrcPath_p;
- if (!(data.devAlias = strdup(devAlias)))
+ if (!(data.target = strdup(target)))
goto mem_error;
data.reason = reason;
diff --git a/examples/domain-events/events-c/event-test.c
b/examples/domain-events/events-c/event-test.c
index 7c99222..adc6d7c 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -293,13 +293,13 @@ static int myDomainEventDiskChangeCallback(virConnectPtr conn
ATTRIBUTE_UNUSED,
virDomainPtr dom,
const char *oldSrcPath,
const char *newSrcPath,
- const char *devAlias,
+ const char *target,
int reason,
void *opaque ATTRIBUTE_UNUSED)
{
- printf("%s EVENT: Domain %s(%d) disk change oldSrcPath: %s newSrcPath: %s
devAlias: %s reason: %s\n",
+ printf("%s EVENT: Domain %s(%d) disk change oldSrcPath: %s newSrcPath: %s
target: %s reason: %s\n",
__func__, virDomainGetName(dom), virDomainGetID(dom),
- oldSrcPath, newSrcPath, devAlias, diskChangeReasonStrings[reason]);
+ oldSrcPath, newSrcPath, target, diskChangeReasonStrings[reason]);
return 0;
}
diff --git a/examples/domain-events/events-python/event-test.py
b/examples/domain-events/events-python/event-test.py
index 9628f6e..5dd6eaa 100644
--- a/examples/domain-events/events-python/event-test.py
+++ b/examples/domain-events/events-python/event-test.py
@@ -469,9 +469,9 @@ def myDomainEventIOErrorCallback(conn, dom, srcpath, devalias, action,
opaque):
def myDomainEventGraphicsCallback(conn, dom, phase, localAddr, remoteAddr, authScheme,
subject, opaque):
print "myDomainEventGraphicsCallback: Domain %s(%s) %d %s" % (dom.name(),
dom.ID(), phase, authScheme)
-def myDomainEventDiskChangeCallback(conn, dom, oldSrcPath, newSrcPath, devAlias, reason,
opaque):
- print "myDomainEventDiskChangeCallback: Domain %s(%s) disk change oldSrcPath: %s
newSrcPath: %s devAlias: %s reason: %s" % (
- dom.name(), dom.ID(), oldSrcPath, newSrcPath, devAlias, reason)
+def myDomainEventDiskChangeCallback(conn, dom, oldSrcPath, newSrcPath, target, reason,
opaque):
+ print "myDomainEventDiskChangeCallback: Domain %s(%s) disk change oldSrcPath: %s
newSrcPath: %s target %s reason: %s" % (
+ dom.name(), dom.ID(), oldSrcPath, newSrcPath, target, reason)
def usage(out=sys.stderr):
print >>out, "usage: "+os.path.basename(sys.argv[0])+" [-hdl]
[uri]"
print >>out, " uri will default to qemu:///system"
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 7102bce..7bcbae6 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -3010,6 +3010,7 @@ typedef enum {
* @dom: domain on which the event occurred
* @oldSrcPath: old source path
* @newSrcPath: new source path
+ * @target: disk target where event occurred
* @reason: reason why this callback was called; any of
* virConnectDomainEventDiskChangeReason
* @opaque: application specified data
@@ -3026,7 +3027,7 @@ typedef void
(*virConnectDomainEventDiskChangeCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *oldSrcPath,
const char *newSrcPath,
- const char *devAlias,
+ const char *target,
int reason,
void *opaque);
diff --git a/python/libvirt-override-virConnect.py
b/python/libvirt-override-virConnect.py
index b908b32..75058d9 100644
--- a/python/libvirt-override-virConnect.py
+++ b/python/libvirt-override-virConnect.py
@@ -125,13 +125,13 @@
except AttributeError:
pass
- def _dispatchDomainEventDiskChangeCallback(self, dom, oldSrcPath, newSrcPath,
devAlias, reason, cbData):
+ def _dispatchDomainEventDiskChangeCallback(self, dom, oldSrcPath, newSrcPath, target,
reason, cbData):
"""Dispatches event to python user domain diskChange event
callbacks
"""
cb = cbData["cb"]
opaque = cbData["opaque"]
- cb(self, virDomain(self, _obj=dom), oldSrcPath, newSrcPath, devAlias, reason,
opaque)
+ cb(self, virDomain(self, _obj=dom), oldSrcPath, newSrcPath, target, reason,
opaque)
return 0;
def domainEventDeregisterAny(self, callbackID):
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 1759bae..310bc00 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -4379,7 +4379,7 @@ libvirt_virConnectDomainEventDiskChangeCallback(virConnectPtr conn
ATTRIBUTE_UNU
virDomainPtr dom,
const char *oldSrcPath,
const char *newSrcPath,
- const char *devAlias,
+ const char *target,
int reason,
void *opaque)
{
@@ -4407,7 +4407,7 @@ libvirt_virConnectDomainEventDiskChangeCallback(virConnectPtr conn
ATTRIBUTE_UNU
(char*)"OsssiO",
pyobj_dom,
oldSrcPath, newSrcPath,
- devAlias, reason, pyobj_cbData);
+ target, reason, pyobj_cbData);
Py_DECREF(pyobj_cbData);
Py_DECREF(pyobj_dom);
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index a04b9d0..2ab68dc 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -91,7 +91,7 @@ struct _virDomainEvent {
struct {
char *oldSrcPath;
char *newSrcPath;
- char *devAlias;
+ char *target;
int reason;
} diskChange;
} data;
@@ -519,7 +519,7 @@ void virDomainEventFree(virDomainEventPtr event)
case VIR_DOMAIN_EVENT_ID_DISK_CHANGE:
VIR_FREE(event->data.diskChange.oldSrcPath);
VIR_FREE(event->data.diskChange.newSrcPath);
- VIR_FREE(event->data.diskChange.devAlias);
+ VIR_FREE(event->data.diskChange.target);
break;
}
@@ -978,14 +978,14 @@ virDomainEventDiskChangeNew(int id, const char *name,
unsigned char *uuid,
const char *oldSrcPath,
const char *newSrcPath,
- const char *devAlias, int reason)
+ const char *target, int reason)
{
virDomainEventPtr ev =
virDomainEventNewInternal(VIR_DOMAIN_EVENT_ID_DISK_CHANGE,
id, name, uuid);
if (ev) {
- if (!(ev->data.diskChange.devAlias = strdup(devAlias)))
+ if (!(ev->data.diskChange.target = strdup(target)))
goto error;
if (oldSrcPath &&
@@ -1010,23 +1010,23 @@ error:
virDomainEventPtr virDomainEventDiskChangeNewFromObj(virDomainObjPtr obj,
const char *oldSrcPath,
const char *newSrcPath,
- const char *devAlias,
+ const char *target,
int reason)
{
return virDomainEventDiskChangeNew(obj->def->id, obj->def->name,
obj->def->uuid, oldSrcPath,
- newSrcPath, devAlias, reason);
+ newSrcPath, target, reason);
}
virDomainEventPtr virDomainEventDiskChangeNewFromDom(virDomainPtr dom,
const char *oldSrcPath,
const char *newSrcPath,
- const char *devAlias,
+ const char *target,
int reason)
{
return virDomainEventDiskChangeNew(dom->id, dom->name, dom->uuid,
oldSrcPath, newSrcPath,
- devAlias, reason);
+ target, reason);
}
/**
@@ -1175,7 +1175,7 @@ void virDomainEventDispatchDefaultFunc(virConnectPtr conn,
((virConnectDomainEventDiskChangeCallback)cb)(conn, dom,
event->data.diskChange.oldSrcPath,
event->data.diskChange.newSrcPath,
-
event->data.diskChange.devAlias,
+ event->data.diskChange.target,
event->data.diskChange.reason,
cbopaque);
break;
diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h
index 3ba418e..6c56fbd 100644
--- a/src/conf/domain_event.h
+++ b/src/conf/domain_event.h
@@ -182,12 +182,12 @@ virDomainEventPtr virDomainEventBlockJobNewFromDom(virDomainPtr
dom,
virDomainEventPtr virDomainEventDiskChangeNewFromObj(virDomainObjPtr obj,
const char *oldSrcPath,
const char *newSrcPath,
- const char *devAlias,
+ const char *target,
int reason);
virDomainEventPtr virDomainEventDiskChangeNewFromDom(virDomainPtr dom,
const char *oldSrcPath,
const char *newSrcPath,
- const char *devAlias,
+ const char *target,
int reason);
int virDomainEventQueuePush(virDomainEventQueuePtr evtQueue,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 198ebcc..82e2d70 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1668,7 +1668,7 @@ qemuDomainCheckDiskPresence(struct qemud_driver *driver,
"due to not accessible source '%s'",
disk->dst, vm->def->name, uuid, disk->src);
- event = virDomainEventDiskChangeNewFromObj(vm, disk->src, NULL,
disk->info.alias,
+ event = virDomainEventDiskChangeNewFromObj(vm, disk->src, NULL, disk->dst,
VIR_DOMAIN_DISK_CHANGE_MISSING_ON_START);
if (event)
qemuDomainEventQueue(driver, event);
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index e98ebd7..8726112 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3354,7 +3354,7 @@ remoteDomainBuildEventDiskChange(virNetClientProgramPtr prog
ATTRIBUTE_UNUSED,
event = virDomainEventDiskChangeNewFromDom(dom,
msg->oldSrcPath ? *msg->oldSrcPath :
NULL,
msg->newSrcPath ? *msg->newSrcPath :
NULL,
- msg->devAlias,
+ msg->target,
msg->reason);
virDomainFree(dom);
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index d135653..8f8c55b 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2014,7 +2014,7 @@ struct remote_domain_event_disk_change_msg {
remote_nonnull_domain dom;
remote_string oldSrcPath;
remote_string newSrcPath;
- remote_nonnull_string devAlias;
+ remote_nonnull_string target;
int reason;
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 569fcb3..fe347fa 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1513,7 +1513,7 @@ struct remote_domain_event_disk_change_msg {
remote_nonnull_domain dom;
remote_string oldSrcPath;
remote_string newSrcPath;
- remote_nonnull_string devAlias;
+ remote_nonnull_string target;
int reason;
};
struct remote_domain_managed_save_args {
--
1.7.3.4