[libvirt] [PATCH] API: Improve log for domain related APIs

Add VM name/UUID in log for domain related APIs. Format: "param0=%p, param1=%p, (VM: %s)" * src/libvirt.c --- src/libvirt.c | 294 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 221 insertions(+), 73 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index ee2495a..03dcafc 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1961,7 +1961,9 @@ error: virConnectPtr virDomainGetConnect (virDomainPtr dom) { - DEBUG("dom=%p", dom); + const char *name = virDomainGetName(dom); + + DEBUG("dom=%p, (VM: %s)", dom, name); virResetLastError(); @@ -2100,7 +2102,10 @@ error: virDomainPtr virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { - DEBUG("conn=%p, uuid=%s", conn, uuid); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(uuid, uuidstr); + + DEBUG("conn=%p, uuid=%s", conn, uuidstr); virResetLastError(); @@ -2226,8 +2231,9 @@ int virDomainDestroy(virDomainPtr domain) { virConnectPtr conn; + const char *name = virDomainGetName(domain); - DEBUG("domain=%p", domain); + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -2270,7 +2276,9 @@ error: int virDomainFree(virDomainPtr domain) { - DEBUG("domain=%p", domain); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -2306,13 +2314,15 @@ virDomainFree(virDomainPtr domain) int virDomainRef(virDomainPtr domain) { + const char *name = virDomainGetName(domain); + if ((!VIR_IS_CONNECTED_DOMAIN(domain))) { virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__); virDispatchError(NULL); return(-1); } virMutexLock(&domain->conn->lock); - DEBUG("domain=%p refs=%d", domain, domain->refs); + DEBUG("domain=%p, refs=%d, (VM: %s)", domain, domain->refs, name); domain->refs++; virMutexUnlock(&domain->conn->lock); return 0; @@ -2335,7 +2345,9 @@ int virDomainSuspend(virDomainPtr domain) { virConnectPtr conn; - DEBUG("domain=%p", domain); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -2380,7 +2392,9 @@ int virDomainResume(virDomainPtr domain) { virConnectPtr conn; - DEBUG("domain=%p", domain); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -2428,7 +2442,9 @@ virDomainSave(virDomainPtr domain, const char *to) { char filepath[4096]; virConnectPtr conn; - DEBUG("domain=%p, to=%s", domain, to); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, to=%s, (VM: %s)", domain, to, name); virResetLastError(); @@ -2570,7 +2586,9 @@ virDomainCoreDump(virDomainPtr domain, const char *to, int flags) { char filepath[4096]; virConnectPtr conn; - DEBUG("domain=%p, to=%s, flags=%d", domain, to, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, to=%s, flags=%d, (VM: %s)", domain, to, flags, name); virResetLastError(); @@ -2647,7 +2665,9 @@ int virDomainShutdown(virDomainPtr domain) { virConnectPtr conn; - DEBUG("domain=%p", domain); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -2693,7 +2713,9 @@ int virDomainReboot(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, flags=%u", domain, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name); virResetLastError(); @@ -2760,7 +2782,9 @@ virDomainGetName(virDomainPtr domain) int virDomainGetUUID(virDomainPtr domain, unsigned char *uuid) { - DEBUG("domain=%p, uuid=%p", domain, uuid); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, uuid=%p, (VM: %s)", domain, uuid, name); virResetLastError(); @@ -2794,7 +2818,9 @@ int virDomainGetUUIDString(virDomainPtr domain, char *buf) { unsigned char uuid[VIR_UUID_BUFLEN]; - DEBUG("domain=%p, buf=%p", domain, buf); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, buf=%p, (VM: %s)", domain, buf, name); virResetLastError(); @@ -2830,7 +2856,9 @@ error: unsigned int virDomainGetID(virDomainPtr domain) { - DEBUG("domain=%p", domain); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -2855,7 +2883,9 @@ char * virDomainGetOSType(virDomainPtr domain) { virConnectPtr conn; - DEBUG("domain=%p", domain); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -2896,7 +2926,9 @@ unsigned long virDomainGetMaxMemory(virDomainPtr domain) { virConnectPtr conn; - DEBUG("domain=%p", domain); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -2942,7 +2974,9 @@ int virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) { virConnectPtr conn; - DEBUG("domain=%p, memory=%lu", domain, memory); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, memory=%lu, (VM: %s)", domain, memory, name); virResetLastError(); @@ -2995,7 +3029,9 @@ int virDomainSetMemory(virDomainPtr domain, unsigned long memory) { virConnectPtr conn; - DEBUG("domain=%p, memory=%lu", domain, memory); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, memory=%lu, (VM: %s)", domain, memory, name); virResetLastError(); @@ -3049,7 +3085,10 @@ virDomainSetMemoryParameters(virDomainPtr domain, int nparams, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, params=%p, nparams=%d, flags=%u", domain, params, nparams, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, params=%p, nparams=%d, flags=%u, (VM: %s)", + domain, params, nparams, flags, name); virResetLastError(); @@ -3123,7 +3162,11 @@ virDomainGetMemoryParameters(virDomainPtr domain, int *nparams, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, params=%p, nparams=%d, flags=%u", domain, params, (nparams)?*nparams:-1, flags); + + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, params=%p, nparams=%d, flags=%u, (VM: %s)", + domain, params, (nparams)?*nparams:-1, flags, name); virResetLastError(); @@ -3167,7 +3210,9 @@ int virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) { virConnectPtr conn; - DEBUG("domain=%p, info=%p", domain, info); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, info=%p, (VM: %s)", domain, info, name); virResetLastError(); @@ -3215,7 +3260,9 @@ char * virDomainGetXMLDesc(virDomainPtr domain, int flags) { virConnectPtr conn; - DEBUG("domain=%p, flags=%d", domain, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, flags=%d, (VM: %s)", domain, flags, name); virResetLastError(); @@ -3662,8 +3709,10 @@ virDomainMigrate (virDomainPtr domain, unsigned long bandwidth) { virDomainPtr ddomain = NULL; - DEBUG("domain=%p, dconn=%p, flags=%lu, dname=%s, uri=%s, bandwidth=%lu", - domain, dconn, flags, NULLSTR(dname), NULLSTR(uri), bandwidth); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, dconn=%p, flags=%lu, dname=%s, uri=%s, bandwidth=%lu, (VM: %s)", + domain, dconn, flags, NULLSTR(dname), NULLSTR(uri), bandwidth, name); virResetLastError(); @@ -3811,8 +3860,10 @@ virDomainMigrateToURI (virDomainPtr domain, const char *dname, unsigned long bandwidth) { - DEBUG("domain=%p, duri=%p, flags=%lu, dname=%s, bandwidth=%lu", - domain, NULLSTR(duri), flags, NULLSTR(dname), bandwidth); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, duri=%p, flags=%lu, dname=%s, bandwidth=%lu, (VM: %s)", + domain, NULLSTR(duri), flags, NULLSTR(dname), bandwidth, name); virResetLastError(); @@ -3924,9 +3975,11 @@ virDomainMigratePerform (virDomainPtr domain, unsigned long bandwidth) { virConnectPtr conn; + const char *name = virDomainGetName(domain); + VIR_DEBUG("domain=%p, cookie=%p, cookielen=%d, uri=%s, flags=%lu, " - "dname=%s, bandwidth=%lu", domain, cookie, cookielen, uri, flags, - NULLSTR(dname), bandwidth); + "dname=%s, bandwidth=%lu, (VM: %s)", domain, cookie, + cookielen, uri, flags, NULLSTR(dname), bandwidth, name); virResetLastError(); @@ -4290,7 +4343,9 @@ virDomainGetSchedulerType(virDomainPtr domain, int *nparams) { virConnectPtr conn; char *schedtype; - DEBUG("domain=%p, nparams=%p", domain, nparams); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, nparams=%p, (VM: %s)", domain, nparams, name); virResetLastError(); @@ -4335,7 +4390,10 @@ virDomainGetSchedulerParameters(virDomainPtr domain, virSchedParameterPtr params, int *nparams) { virConnectPtr conn; - DEBUG("domain=%p, params=%p, nparams=%p", domain, params, nparams); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, params=%p, nparams=%p, (VM: %s)", domain, + params, nparams, name); virResetLastError(); @@ -4378,7 +4436,10 @@ virDomainSetSchedulerParameters(virDomainPtr domain, virSchedParameterPtr params, int nparams) { virConnectPtr conn; - DEBUG("domain=%p, params=%p, nparams=%d", domain, params, nparams); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, params=%p, nparams=%d, (VM: %s)", domain, + params, nparams, name); virResetLastError(); @@ -4438,7 +4499,10 @@ virDomainBlockStats (virDomainPtr dom, const char *path, { virConnectPtr conn; struct _virDomainBlockStats stats2 = { -1, -1, -1, -1, -1 }; - DEBUG("domain=%p, path=%s, stats=%p, size=%zi", dom, path, stats, size); + const char *name = virDomainGetName(dom); + + DEBUG("domain=%p, path=%s, stats=%p, size=%zi, (VM: %s)", dom, + path, stats, size, name); virResetLastError(); @@ -4496,7 +4560,10 @@ virDomainInterfaceStats (virDomainPtr dom, const char *path, virConnectPtr conn; struct _virDomainInterfaceStats stats2 = { -1, -1, -1, -1, -1, -1, -1, -1 }; - DEBUG("domain=%p, path=%s, stats=%p, size=%zi", dom, path, stats, size); + const char *name = virDomainGetName(dom); + + DEBUG("domain=%p, path=%s, stats=%p, size=%zi, (VM: %s)", dom, + path, stats, size, name); virResetLastError(); @@ -4561,7 +4628,9 @@ int virDomainMemoryStats (virDomainPtr dom, virDomainMemoryStatPtr stats, { virConnectPtr conn; unsigned long nr_stats_ret = 0; - DEBUG("domain=%p, stats=%p, nr_stats=%u", dom, stats, nr_stats); + const char *name = virDomainGetName(dom); + + DEBUG("domain=%p, stats=%p, nr_stats=%u, (VM: %s)", dom, stats, nr_stats, name); if (flags != 0) { virLibDomainError (dom, VIR_ERR_INVALID_ARG, @@ -4645,8 +4714,10 @@ virDomainBlockPeek (virDomainPtr dom, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, path=%s, offset=%lld, size=%zi, buffer=%p", - dom, path, offset, size, buffer); + const char *name = virDomainGetName(dom); + + DEBUG("domain=%p, path=%s, offset=%lld, size=%zi, buffer=%p, (VM: %s)", + dom, path, offset, size, buffer, name); virResetLastError(); @@ -4736,8 +4807,10 @@ virDomainMemoryPeek (virDomainPtr dom, unsigned int flags) { virConnectPtr conn; - DEBUG ("domain=%p, start=%lld, size=%zi, buffer=%p, flags=%d", - dom, start, size, buffer, flags); + const char *name = virDomainGetName(dom); + + DEBUG ("domain=%p, start=%lld, size=%zi, buffer=%p, flags=%d, (VM: %s)", + dom, start, size, buffer, flags, name); virResetLastError(); @@ -4821,7 +4894,9 @@ int virDomainGetBlockInfo(virDomainPtr domain, const char *path, virDomainBlockInfoPtr info, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, info=%p flags=%u", domain, info, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, info=%p flags=%u, (VM: %s)", domain, info, flags, name); virResetLastError(); @@ -4919,7 +4994,11 @@ error: int virDomainUndefine(virDomainPtr domain) { virConnectPtr conn; - DEBUG("domain=%p", domain); + const char *name; + + name = virDomainGetName(domain); + + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -5041,7 +5120,9 @@ error: int virDomainCreate(virDomainPtr domain) { virConnectPtr conn; - DEBUG("domain=%p", domain); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, (VM :%s)", domain, name); virResetLastError(); @@ -5084,7 +5165,9 @@ error: int virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, flags=%d", domain, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, flags=%d, (VM: %s)", domain, flags, name); virResetLastError(); @@ -5130,7 +5213,9 @@ virDomainGetAutostart(virDomainPtr domain, int *autostart) { virConnectPtr conn; - DEBUG("domain=%p, autostart=%p", domain, autostart); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, autostart=%p, (VM: %s)", domain, autostart, name); virResetLastError(); @@ -5176,7 +5261,9 @@ virDomainSetAutostart(virDomainPtr domain, int autostart) { virConnectPtr conn; - DEBUG("domain=%p, autostart=%d", domain, autostart); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, autostart=%d, (VM: %s)", domain, autostart, name); virResetLastError(); @@ -5230,7 +5317,9 @@ int virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) { virConnectPtr conn; - DEBUG("domain=%p, nvcpus=%u", domain, nvcpus); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, nvcpus=%u, (VM: %s)", domain, nvcpus, name); virResetLastError(); @@ -5296,7 +5385,10 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, nvcpus=%u, flags=%u", domain, nvcpus, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, nvcpus=%u, flags=%u, (VM: %s)", domain, + nvcpus, flags, name); virResetLastError(); @@ -5359,7 +5451,9 @@ int virDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, flags=%u", domain, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name); virResetLastError(); @@ -5417,7 +5511,10 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu, unsigned char *cpumap, int maplen) { virConnectPtr conn; - DEBUG("domain=%p, vcpu=%u, cpumap=%p, maplen=%d", domain, vcpu, cpumap, maplen); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, vcpu=%u, cpumap=%p, maplen=%d, (VM: %s)", + domain, vcpu, cpumap, maplen, name); virResetLastError(); @@ -5480,7 +5577,10 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo, unsigned char *cpumaps, int maplen) { virConnectPtr conn; - DEBUG("domain=%p, info=%p, maxinfo=%d, cpumaps=%p, maplen=%d", domain, info, maxinfo, cpumaps, maplen); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, info=%p, maxinfo=%d, cpumaps=%p, maplen=%d, (VM: %s)", + domain, info, maxinfo, cpumaps, maplen, name); virResetLastError(); @@ -5536,7 +5636,9 @@ int virDomainGetMaxVcpus(virDomainPtr domain) { virConnectPtr conn; - DEBUG("domain=%p", domain); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -5665,7 +5767,9 @@ int virDomainAttachDevice(virDomainPtr domain, const char *xml) { virConnectPtr conn; - DEBUG("domain=%p, xml=%s", domain, xml); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, xml=%s, (VM: %s)", domain, xml, name); virResetLastError(); @@ -5724,7 +5828,9 @@ virDomainAttachDeviceFlags(virDomainPtr domain, const char *xml, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml, flags, name); virResetLastError(); @@ -5767,7 +5873,9 @@ int virDomainDetachDevice(virDomainPtr domain, const char *xml) { virConnectPtr conn; - DEBUG("domain=%p, xml=%s", domain, xml); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, xml=%s, (VM: %s)", domain, xml, name); virResetLastError(); @@ -5822,7 +5930,11 @@ virDomainDetachDeviceFlags(virDomainPtr domain, const char *xml, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags); + const char *name; + + name = virDomainGetName(domain); + + DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml, flags, name); virResetLastError(); @@ -5880,7 +5992,9 @@ virDomainUpdateDeviceFlags(virDomainPtr domain, const char *xml, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml, flags, name); virResetLastError(); @@ -6206,7 +6320,10 @@ error: virNetworkPtr virNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { - DEBUG("conn=%p, uuid=%s", conn, uuid); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(uuid, uuidstr); + + DEBUG("conn=%p, uuid=%s", conn, uuidstr); virResetLastError(); @@ -11431,7 +11548,9 @@ error: */ int virDomainIsPersistent(virDomainPtr dom) { - DEBUG("dom=%p", dom); + const char *name = virDomainGetName(dom); + + DEBUG("domain=%p, (VM: %s)", dom, name); virResetLastError(); @@ -11464,7 +11583,9 @@ error: */ int virDomainIsUpdated(virDomainPtr dom) { - DEBUG("dom=%p", dom); + const char *name = virDomainGetName(dom); + + DEBUG("domain=%p, (VM: %s)", dom, name); virResetLastError(); @@ -12353,7 +12474,9 @@ int virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info) { virConnectPtr conn; - DEBUG("domain=%p, info=%p", domain, info); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, info=%p, (VM: %s)", domain, info, name); virResetLastError(); @@ -12401,8 +12524,9 @@ int virDomainAbortJob(virDomainPtr domain) { virConnectPtr conn; + const char *name = virDomainGetName(domain); - DEBUG("domain=%p", domain); + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -12452,8 +12576,10 @@ virDomainMigrateSetMaxDowntime(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; + const char *name = virDomainGetName(domain); - DEBUG("domain=%p, downtime=%llu, flags=%u", domain, downtime, flags); + DEBUG("domain=%p, downtime=%llu, flags=%u, (VM: %s)", domain, + downtime, flags, name); virResetLastError(); @@ -12522,7 +12648,12 @@ virConnectDomainEventRegisterAny(virConnectPtr conn, void *opaque, virFreeCallback freecb) { - DEBUG("conn=%p dom=%p, eventID=%d, cb=%p, opaque=%p, freecb=%p", conn, dom, eventID, cb, opaque, freecb); + const char *name; + + name = virDomainGetName(dom); + + DEBUG("conn=%p, domain=%p, eventID=%d, cb=%p, opaque=%p, freecb=%p, (VM: %s)", + conn, dom, eventID, cb, opaque, freecb, name); virResetLastError(); if (!VIR_IS_CONNECT(conn)) { @@ -12614,8 +12745,9 @@ error: int virDomainManagedSave(virDomainPtr dom, unsigned int flags) { virConnectPtr conn; + const char *name = virDomainGetName(dom); - VIR_DEBUG("dom=%p, flags=%u", dom, flags); + VIR_DEBUG("dom%p, flags=%u, (VM: %s)", dom, flags, name); virResetLastError(); @@ -12662,8 +12794,9 @@ error: int virDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) { virConnectPtr conn; + const char *name = virDomainGetName(dom); - VIR_DEBUG("dom=%p, flags=%u", dom, flags); + VIR_DEBUG("dom=%p, flags=%u, (VM: %s)", dom, flags, name); virResetLastError(); @@ -12703,8 +12836,9 @@ error: int virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) { virConnectPtr conn; + const char *name = virDomainGetName(dom); - VIR_DEBUG("dom=%p, flags=%u", dom, flags); + VIR_DEBUG("dom=%p, flags=%u, (VM: %s)", dom, flags, name); virResetLastError(); @@ -12753,8 +12887,9 @@ virDomainSnapshotCreateXML(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; + const char *name = virDomainGetName(domain); - DEBUG("domain=%p, xmlDesc=%s, flags=%u", domain, xmlDesc, flags); + DEBUG("domain=%p, xmlDesc=%s, flags=%u, (VM: %s)", domain, xmlDesc, flags, name); virResetLastError(); @@ -12845,7 +12980,9 @@ int virDomainSnapshotNum(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p", domain); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, (VM: %s)", domain, name); virResetLastError(); @@ -12887,9 +13024,10 @@ virDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen, unsigned int flags) { virConnectPtr conn; + const char *name = virDomainGetName(domain); - DEBUG("domain=%p, names=%p, nameslen=%d, flags=%u", - domain, names, nameslen, flags); + DEBUG("domain=%p, names=%p, nameslen=%d, flags=%u, (VM: %s)", + domain, names, nameslen, flags, name); virResetLastError(); @@ -12938,7 +13076,10 @@ virDomainSnapshotLookupByName(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, name=%s, flags=%u", domain, name, flags); + const char *domname = virDomainGetName(domain); + + DEBUG("domain=%p, name=%s, flags=%u, (VM: %s)", domain, name, + flags, domname); virResetLastError(); @@ -12982,7 +13123,9 @@ int virDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, flags=%u", domain, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name); virResetLastError(); @@ -13023,7 +13166,9 @@ virDomainSnapshotCurrent(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; - DEBUG("domain=%p, flags=%u", domain, flags); + const char *name = virDomainGetName(domain); + + DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name); virResetLastError(); @@ -13187,7 +13332,10 @@ int virDomainOpenConsole(virDomainPtr dom, unsigned int flags) { virConnectPtr conn; - DEBUG("dom=%p devname=%s, st=%p flags=%u", dom, NULLSTR(devname), st, flags); + const char *name = virDomainGetName(dom); + + DEBUG("dom=%p, devname=%s, st=%p, flags=%u, (VM: %s)", dom, + NULLSTR(devname), st, flags, name); virResetLastError(); -- 1.7.3.2

On 12/23/2010 06:53 AM, Osier Yang wrote:
Add VM name/UUID in log for domain related APIs. Format: "param0=%p, param1=%p, (VM: %s)"
* src/libvirt.c --- src/libvirt.c | 294 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 221 insertions(+), 73 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index ee2495a..03dcafc 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1961,7 +1961,9 @@ error: virConnectPtr virDomainGetConnect (virDomainPtr dom) { - DEBUG("dom=%p", dom); + const char *name = virDomainGetName(dom); + + DEBUG("dom=%p, (VM: %s)", dom, name);
virDomainGetName() can return NULL, so you'd need to use NULLSTR(name) everywhere. That alone requires a v2, but I'd wait for feedback from danpb or DV as to whether this makes sense. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Thu, Dec 23, 2010 at 09:57:15AM -0700, Eric Blake wrote:
On 12/23/2010 06:53 AM, Osier Yang wrote:
Add VM name/UUID in log for domain related APIs. Format: "param0=%p, param1=%p, (VM: %s)"
* src/libvirt.c --- src/libvirt.c | 294 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 221 insertions(+), 73 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index ee2495a..03dcafc 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1961,7 +1961,9 @@ error: virConnectPtr virDomainGetConnect (virDomainPtr dom) { - DEBUG("dom=%p", dom); + const char *name = virDomainGetName(dom); + + DEBUG("dom=%p, (VM: %s)", dom, name);
virDomainGetName() can return NULL, so you'd need to use NULLSTR(name) everywhere. That alone requires a v2, but I'd wait for feedback from danpb or DV as to whether this makes sense.
Whether what makes sense? Dave

On 12/23/2010 11:00 AM, Dave Allan wrote:
virConnectPtr virDomainGetConnect (virDomainPtr dom) { - DEBUG("dom=%p", dom); + const char *name = virDomainGetName(dom); + + DEBUG("dom=%p, (VM: %s)", dom, name);
virDomainGetName() can return NULL, so you'd need to use NULLSTR(name) everywhere. That alone requires a v2, but I'd wait for feedback from danpb or DV as to whether this makes sense.
Whether what makes sense?
Do we risk any deadlocks by calling a public API (virDomainGetName) from within the body of another public API (such as virDomainGetConnect)? If there is any risk, then the extra debug information is not worth it. But if it's always safe to do, then I like the idea of the extra information, even though it adds a slight amount of time to execute each domain-related API. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

于 2010年12月24日 00:57, Eric Blake 写道:
On 12/23/2010 06:53 AM, Osier Yang wrote:
Add VM name/UUID in log for domain related APIs. Format: "param0=%p, param1=%p, (VM: %s)"
* src/libvirt.c --- src/libvirt.c | 294 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 221 insertions(+), 73 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index ee2495a..03dcafc 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1961,7 +1961,9 @@ error: virConnectPtr virDomainGetConnect (virDomainPtr dom) { - DEBUG("dom=%p", dom); + const char *name = virDomainGetName(dom); + + DEBUG("dom=%p, (VM: %s)", dom, name);
virDomainGetName() can return NULL, so you'd need to use NULLSTR(name) everywhere. That alone requires a v2, but I'd wait for feedback from danpb or DV as to whether this makes sense.
Thanks, sent v2 patch with NULLSTR(name), wait for your feedback there. Regards Osier
participants (3)
-
Dave Allan
-
Eric Blake
-
Osier Yang