[libvirt] [PATCH 00/24] libvirt.c error handling audit

This series is in response to: https://www.redhat.com/archives/libvir-list/2013-December/msg01101.html It turned into a much bigger cleanup project, where I ended up with a lot of changes; hopefully the division into multiple patches makes review easier, and the end result diffstat shows that the code base is more compact when all is said and done. Eric Blake (24): maint: consistent formatting in libvirt.c maint: improve debug of libvirt-{qemu,lxc} apis maint: move debug statements first in public API maint: improve error condition style in public API maint: don't leave garbage on early API exit maint: reset error on entrance to public API maint: avoid nested public calls maint: improve VIR_ERR_NO_SUPPORT usage maint: improve VIR_ERR_OPERATION_DENIED usage maint: improve VIR_ERR_INVALID_CONN usage maint: inline VIR_IS_CONNECT macro maint: improve VIR_ERR_INVALID_DOMAIN usage maint: inline VIR_IS*_DOMAIN macro maint: improve VIR_ERR_INVALID_NETWORK usage maint: improve VIR_ERR_INVALID_INTERFACE usage maint: improve VIR_ERR_INVALID_STORAGE_POOL usage maint: improve VIR_ERR_INVALID_STORAGE_VOL usage maint: improve VIR_ERR_INVALID_NODE_DEVICE usage maint: improve VIR_ERR_INVALID_SECRET usage maint: improve VIR_ERR_INVALID_STREAM usage maint: improve VIR_ERR_INVALID_NWFILTER usage maint: improve VIR_ERR_INVALID_DOMAIN_SNAPSHOT usage maint: clean up error reporting in migration maint: replace remaining virLib*Error with better names cfg.mk | 10 - docs/api_extension.html.in | 7 +- po/POTFILES.in | 1 - src/datatypes.c | 104 +- src/datatypes.h | 318 ++- src/internal.h | 9 + src/libvirt-lxc.c | 38 +- src/libvirt-qemu.c | 65 +- src/libvirt.c | 5342 +++++++++++++-------------------------- src/locking/lock_daemon.c | 16 +- src/lxc/lxc_driver.c | 2 +- src/qemu/qemu_migration.c | 10 +- src/security/security_manager.c | 46 +- src/util/virerror.c | 2 +- src/util/virerror.h | 8 + src/util/virinitctl.c | 4 +- src/util/virtypedparam.c | 14 +- src/util/viruuid.h | 20 +- src/xen/xen_driver.c | 11 +- 19 files changed, 2250 insertions(+), 3777 deletions(-) -- 1.8.4.2

Preliminary cleanups to make search-and-replace easier in later patches. * src/libvirt.c: Uniform two spaces between functions, return type and open brace on separate line, and label in column 1. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 718 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 536 insertions(+), 182 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 6aaa3a4..8066b7c 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -128,7 +128,9 @@ static int virStateDriverTabCount = 0; #if defined(POLKIT_AUTH) -static int virConnectAuthGainPolkit(const char *privilege) { +static int +virConnectAuthGainPolkit(const char *privilege) +{ virCommandPtr cmd; int status; int ret = -1; @@ -148,9 +150,12 @@ cleanup: } #endif -static int virConnectAuthCallbackDefault(virConnectCredentialPtr cred, - unsigned int ncred, - void *cbdata ATTRIBUTE_UNUSED) { + +static int +virConnectAuthCallbackDefault(virConnectCredentialPtr cred, + unsigned int ncred, + void *cbdata ATTRIBUTE_UNUSED) +{ size_t i; for (i = 0; i < ncred; i++) { @@ -225,6 +230,7 @@ static int virConnectAuthCallbackDefault(virConnectCredentialPtr cred, return 0; } + /* Don't typically want VIR_CRED_USERNAME. It enables you to authenticate * as one user, and act as another. It just results in annoying * prompts for the username twice & is very rarely what you want @@ -273,7 +279,8 @@ winsock_init(void) #ifdef WITH_GNUTLS_GCRYPT -static int virTLSMutexInit(void **priv) +static int +virTLSMutexInit(void **priv) { virMutexPtr lock = NULL; @@ -289,7 +296,9 @@ static int virTLSMutexInit(void **priv) return 0; } -static int virTLSMutexDestroy(void **priv) + +static int +virTLSMutexDestroy(void **priv) { virMutexPtr lock = *priv; virMutexDestroy(lock); @@ -297,20 +306,25 @@ static int virTLSMutexDestroy(void **priv) return 0; } -static int virTLSMutexLock(void **priv) + +static int +virTLSMutexLock(void **priv) { virMutexPtr lock = *priv; virMutexLock(lock); return 0; } -static int virTLSMutexUnlock(void **priv) + +static int +virTLSMutexUnlock(void **priv) { virMutexPtr lock = *priv; virMutexUnlock(lock); return 0; } + static struct gcry_thread_cbs virTLSThreadImpl = { /* GCRY_THREAD_OPTION_VERSION was added in gcrypt 1.4.2 */ # ifdef GCRY_THREAD_OPTION_VERSION @@ -506,6 +520,7 @@ error: virGlobalError = true; } + /** * virInitialize: * @@ -532,6 +547,7 @@ virInitialize(void) return 0; } + #ifdef WIN32 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID ignore); @@ -566,6 +582,7 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, } #endif + #define virLibConnError(code, ...) \ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) @@ -628,6 +645,7 @@ virRegisterNetworkDriver(virNetworkDriverPtr driver) return virNetworkDriverTabCount++; } + /** * virRegisterInterfaceDriver: * @driver: pointer to an interface driver block @@ -655,6 +673,7 @@ virRegisterInterfaceDriver(virInterfaceDriverPtr driver) return virInterfaceDriverTabCount++; } + /** * virRegisterStorageDriver: * @driver: pointer to a storage driver block @@ -682,6 +701,7 @@ virRegisterStorageDriver(virStorageDriverPtr driver) return virStorageDriverTabCount++; } + /** * virRegisterNodeDeviceDriver: * @driver: pointer to a device monitor block @@ -709,6 +729,7 @@ virRegisterNodeDeviceDriver(virNodeDeviceDriverPtr driver) return virNodeDeviceDriverTabCount++; } + /** * virRegisterSecretDriver: * @driver: pointer to a secret driver block @@ -736,6 +757,7 @@ virRegisterSecretDriver(virSecretDriverPtr driver) return virSecretDriverTabCount++; } + /** * virRegisterNWFilterDriver: * @driver: pointer to a network filter driver block @@ -793,6 +815,7 @@ virRegisterDriver(virDriverPtr driver) return virDriverTabCount++; } + #ifdef WITH_LIBVIRTD /** * virRegisterStateDriver: @@ -818,6 +841,7 @@ virRegisterStateDriver(virStateDriverPtr driver) return virStateDriverTabCount++; } + /** * virStateInitialize: * @privileged: set to true if running with root privilege, false otherwise @@ -832,9 +856,10 @@ virRegisterStateDriver(virStateDriverPtr driver) * * Returns 0 if all succeed, -1 upon any failure. */ -int virStateInitialize(bool privileged, - virStateInhibitCallback callback, - void *opaque) +int +virStateInitialize(bool privileged, + virStateInhibitCallback callback, + void *opaque) { size_t i; @@ -867,6 +892,7 @@ int virStateInitialize(bool privileged, return 0; } + /** * virStateCleanup: * @@ -874,7 +900,9 @@ int virStateInitialize(bool privileged, * * Returns 0 if all succeed, -1 upon any failure. */ -int virStateCleanup(void) { +int +virStateCleanup(void) +{ size_t i; int ret = 0; @@ -886,6 +914,7 @@ int virStateCleanup(void) { return ret; } + /** * virStateReload: * @@ -893,7 +922,9 @@ int virStateCleanup(void) { * * Returns 0 if all succeed, -1 upon any failure. */ -int virStateReload(void) { +int +virStateReload(void) +{ size_t i; int ret = 0; @@ -905,6 +936,7 @@ int virStateReload(void) { return ret; } + /** * virStateStop: * @@ -912,7 +944,9 @@ int virStateReload(void) { * * Returns 0 if successful, -1 on failure */ -int virStateStop(void) { +int +virStateStop(void) +{ size_t i; int ret = 0; @@ -923,9 +957,7 @@ int virStateStop(void) { } return ret; } - -#endif - +#endif /* WITH_LIBVIRTD */ /** @@ -971,6 +1003,7 @@ error: return -1; } + static char * virConnectGetConfigFilePath(void) { @@ -995,6 +1028,7 @@ virConnectGetConfigFilePath(void) return path; } + static int virConnectGetConfigFile(virConfPtr *conf) { @@ -1024,8 +1058,10 @@ cleanup: #define URI_ALIAS_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-" + static int -virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, char **uri) +virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, + char **uri) { virConfValuePtr entry; size_t alias_len; @@ -1078,6 +1114,7 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, char * return 0; } + static int virConnectOpenResolveURIAlias(virConfPtr conf, const char *alias, char **uri) @@ -1121,6 +1158,7 @@ cleanup: return ret; } + static virConnectPtr do_open(const char *name, virConnectAuthPtr auth, @@ -1372,6 +1410,7 @@ failed: return NULL; } + /** * virConnectOpen: * @name: (optional) URI of the hypervisor @@ -1414,6 +1453,7 @@ error: return NULL; } + /** * virConnectOpenReadOnly: * @name: (optional) URI of the hypervisor @@ -1449,6 +1489,7 @@ error: return NULL; } + /** * virConnectOpenAuth: * @name: (optional) URI of the hypervisor @@ -1488,6 +1529,7 @@ error: return NULL; } + /** * virConnectClose: * @conn: pointer to the hypervisor connection @@ -1538,6 +1580,7 @@ error: return ret; } + /** * virConnectRef: * @conn: the connection to hold a reference on @@ -1568,6 +1611,7 @@ virConnectRef(virConnectPtr conn) return 0; } + /* * Not for public use. This function is part of the internal * implementation of driver features in the remote case. @@ -1597,6 +1641,7 @@ virConnectSupportsFeature(virConnectPtr conn, int feature) return ret; } + /** * virConnectGetType: * @conn: pointer to the hypervisor connection @@ -1633,6 +1678,7 @@ virConnectGetType(virConnectPtr conn) return conn->driver->name; } + /** * virConnectGetVersion: * @conn: pointer to the hypervisor connection @@ -1675,6 +1721,7 @@ error: return -1; } + /** * virConnectGetLibVersion: * @conn: pointer to the hypervisor connection @@ -1717,6 +1764,7 @@ error: return ret; } + /** * virConnectGetHostname: * @conn: pointer to a hypervisor connection @@ -1757,6 +1805,7 @@ error: return NULL; } + /** * virConnectGetURI: * @conn: pointer to a hypervisor connection @@ -1796,6 +1845,7 @@ error: return NULL; } + /** * virConnectGetSysinfo: * @conn: pointer to a hypervisor connection @@ -1836,6 +1886,7 @@ error: return NULL; } + /** * virConnectGetMaxVcpus: * @conn: pointer to the hypervisor connection @@ -1874,6 +1925,7 @@ error: return -1; } + /** * virConnectListDomains: * @conn: pointer to the hypervisor connection @@ -1920,6 +1972,7 @@ error: return -1; } + /** * virConnectNumOfDomains: * @conn: pointer to the hypervisor connection @@ -1954,6 +2007,7 @@ error: return -1; } + /** * virDomainGetConnect: * @dom: pointer to a domain @@ -1983,6 +2037,7 @@ virDomainGetConnect(virDomainPtr dom) return dom->conn; } + /** * virDomainCreateXML: * @conn: pointer to the hypervisor connection @@ -2042,6 +2097,7 @@ error: return NULL; } + /** * virDomainCreateXMLWithFiles: * @conn: pointer to the hypervisor connection @@ -2115,6 +2171,7 @@ error: return NULL; } + /** * virDomainCreateLinux: * @conn: pointer to the hypervisor connection @@ -2134,6 +2191,7 @@ virDomainCreateLinux(virConnectPtr conn, const char *xmlDesc, return virDomainCreateXML(conn, xmlDesc, flags); } + /** * virDomainLookupByID: * @conn: pointer to the hypervisor connection @@ -2175,6 +2233,7 @@ error: return NULL; } + /** * virDomainLookupByUUID: * @conn: pointer to the hypervisor connection @@ -2214,6 +2273,7 @@ error: return NULL; } + /** * virDomainLookupByUUIDString: * @conn: pointer to the hypervisor connection @@ -2253,6 +2313,7 @@ error: return NULL; } + /** * virDomainLookupByName: * @conn: pointer to the hypervisor connection @@ -2292,6 +2353,7 @@ error: return NULL; } + /** * virDomainDestroy: * @domain: a domain object @@ -2352,6 +2414,7 @@ error: return -1; } + /** * virDomainDestroyFlags: * @domain: a domain object @@ -2418,6 +2481,7 @@ error: return -1; } + /** * virDomainFree: * @domain: a domain object @@ -2443,6 +2507,7 @@ virDomainFree(virDomainPtr domain) return 0; } + /** * virDomainRef: * @domain: the domain to hold a reference on @@ -2525,6 +2590,7 @@ error: return -1; } + /** * virDomainResume: * @domain: a domain object @@ -2573,6 +2639,7 @@ error: return -1; } + /** * virDomainPMSuspendForDuration: * @dom: a domain object @@ -2641,6 +2708,7 @@ error: return -1; } + /** * virDomainPMWakeup: * @dom: a domain object @@ -2691,6 +2759,7 @@ error: return -1; } + /** * virDomainSave: * @domain: a domain object @@ -2755,6 +2824,7 @@ error: return -1; } + /** * virDomainSaveFlags: * @domain: a domain object @@ -2850,6 +2920,7 @@ error: return -1; } + /** * virDomainRestore: * @conn: pointer to the hypervisor connection @@ -2906,6 +2977,7 @@ error: return -1; } + /** * virDomainRestoreFlags: * @conn: pointer to the hypervisor connection @@ -2989,6 +3061,7 @@ error: return -1; } + /** * virDomainSaveImageGetXMLDesc: * @conn: pointer to the hypervisor connection @@ -3057,6 +3130,7 @@ error: return NULL; } + /** * virDomainSaveImageDefineXML: * @conn: pointer to the hypervisor connection @@ -3138,6 +3212,7 @@ error: return -1; } + /** * virDomainCoreDump: * @domain: a domain object @@ -3229,6 +3304,7 @@ error: return -1; } + /** * virDomainScreenshot: * @domain: a domain object @@ -3294,6 +3370,7 @@ error: return NULL; } + /** * virDomainShutdown: * @domain: a domain object @@ -3350,6 +3427,7 @@ error: return -1; } + /** * virDomainShutdownFlags: * @domain: a domain object @@ -3413,6 +3491,7 @@ error: return -1; } + /** * virDomainReboot: * @domain: a domain object @@ -3477,6 +3556,7 @@ error: return -1; } + /** * virDomainReset: * @domain: a domain object @@ -3527,6 +3607,7 @@ error: return -1; } + /** * virDomainGetName: * @domain: a domain object @@ -3551,6 +3632,7 @@ virDomainGetName(virDomainPtr domain) return domain->name; } + /** * virDomainGetUUID: * @domain: a domain object @@ -3579,6 +3661,7 @@ virDomainGetUUID(virDomainPtr domain, unsigned char *uuid) return 0; } + /** * virDomainGetUUIDString: * @domain: a domain object @@ -3616,6 +3699,7 @@ error: return -1; } + /** * virDomainGetID: * @domain: a domain object @@ -3639,6 +3723,7 @@ virDomainGetID(virDomainPtr domain) return domain->id; } + /** * virDomainGetOSType: * @domain: a domain object @@ -3680,6 +3765,7 @@ error: return NULL; } + /** * virDomainGetMaxMemory: * @domain: a domain object or NULL @@ -3728,6 +3814,7 @@ error: return 0; } + /** * virDomainSetMaxMemory: * @domain: a domain object or NULL @@ -3781,6 +3868,7 @@ error: return -1; } + /** * virDomainSetMemory: * @domain: a domain object or NULL @@ -3833,6 +3921,7 @@ error: return -1; } + /** * virDomainSetMemoryFlags: * @domain: a domain object or NULL @@ -3858,7 +3947,6 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - int virDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, unsigned int flags) @@ -3898,6 +3986,7 @@ error: return -1; } + /** * virDomainSetMemoryStatsPeriod: * @domain: a domain object or NULL @@ -3920,7 +4009,6 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - int virDomainSetMemoryStatsPeriod(virDomainPtr domain, int period, unsigned int flags) @@ -3962,6 +4050,7 @@ error: return -1; } + /* Helper function called to validate incoming client array on any * interface that sets typed parameters in the hypervisor. */ static int @@ -4003,6 +4092,7 @@ virTypedParameterValidateSet(virConnectPtr conn, return 0; } + /** * virDomainSetMemoryParameters: * @domain: pointer to domain object @@ -4061,6 +4151,7 @@ error: return -1; } + /** * virDomainGetMemoryParameters: * @domain: pointer to domain object @@ -4146,6 +4237,7 @@ error: return -1; } + /** * virDomainSetNumaParameters: * @domain: pointer to domain object @@ -4204,6 +4296,7 @@ error: return -1; } + /** * virDomainGetNumaParameters: * @domain: pointer to domain object @@ -4230,7 +4323,6 @@ error: * * Returns -1 in case of error, 0 in case of success. */ - int virDomainGetNumaParameters(virDomainPtr domain, virTypedParameterPtr params, @@ -4274,6 +4366,7 @@ error: return -1; } + /** * virDomainSetBlkioParameters: * @domain: pointer to domain object @@ -4332,6 +4425,7 @@ error: return -1; } + /** * virDomainGetBlkioParameters: * @domain: pointer to domain object @@ -4408,6 +4502,7 @@ error: return -1; } + /** * virDomainGetInfo: * @domain: a domain object @@ -4454,6 +4549,7 @@ error: return -1; } + /** * virDomainGetState: * @domain: a domain object @@ -4503,6 +4599,7 @@ error: return -1; } + /** * virDomainGetControlInfo: * @domain: a domain object @@ -4548,6 +4645,7 @@ error: return -1; } + /** * virDomainGetXMLDesc: * @domain: a domain object @@ -4607,6 +4705,7 @@ error: return NULL; } + /** * virConnectDomainXMLFromNative: * @conn: a connection object @@ -4662,6 +4761,7 @@ error: return NULL; } + /** * virConnectDomainXMLToNative: * @conn: a connection object @@ -4802,12 +4902,13 @@ virDomainMigrateVersion1(virDomainPtr domain, else ddomain = virDomainLookupByName(dconn, dname); - done: +done: VIR_FREE(uri_out); VIR_FREE(cookie); return ddomain; } + /* * Sequence v2: * @@ -4933,7 +5034,7 @@ finish: ddomain = dconn->driver->domainMigrateFinish2 (dconn, dname, cookie, cookielen, uri, destflags, cancelled); - done: +done: if (orig_err) { virSetError(orig_err); virFreeError(orig_err); @@ -5228,7 +5329,7 @@ confirm: } } - done: +done: if (orig_err) { virSetError(orig_err); virFreeError(orig_err); @@ -5241,6 +5342,7 @@ confirm: return ddomain; } + static virDomainPtr virDomainMigrateVersion3(virDomainPtr domain, virConnectPtr dconn, @@ -5254,6 +5356,7 @@ virDomainMigrateVersion3(virDomainPtr domain, bandwidth, NULL, 0, false, flags); } + static virDomainPtr virDomainMigrateVersion3Params(virDomainPtr domain, virConnectPtr dconn, @@ -5266,20 +5369,20 @@ virDomainMigrateVersion3Params(virDomainPtr domain, } - /* - * In normal migration, the libvirt client co-ordinates communication - * between the 2 libvirtd instances on source & dest hosts. - * - * In this peer-2-peer migration alternative, the libvirt client - * only talks to the source libvirtd instance. The source libvirtd - * then opens its own connection to the destination and co-ordinates - * migration itself. - * - * If useParams is true, params and nparams contain migration parameters and - * we know it's safe to call the API which supports extensible parameters. - * Otherwise, we have to use xmlin, dname, uri, and bandwidth and pass them - * to the old-style APIs. - */ +/* + * In normal migration, the libvirt client co-ordinates communication + * between the 2 libvirtd instances on source & dest hosts. + * + * In this peer-2-peer migration alternative, the libvirt client + * only talks to the source libvirtd instance. The source libvirtd + * then opens its own connection to the destination and co-ordinates + * migration itself. + * + * If useParams is true, params and nparams contain migration parameters and + * we know it's safe to call the API which supports extensible parameters. + * Otherwise, we have to use xmlin, dname, uri, and bandwidth and pass them + * to the old-style APIs. + */ static int virDomainMigratePeer2PeerFull(virDomainPtr domain, const char *dconnuri, @@ -5349,6 +5452,7 @@ virDomainMigratePeer2PeerFull(virDomainPtr domain, } } + static int virDomainMigratePeer2Peer(virDomainPtr domain, const char *xmlin, @@ -5362,6 +5466,7 @@ virDomainMigratePeer2Peer(virDomainPtr domain, bandwidth, NULL, 0, false, flags); } + static int virDomainMigratePeer2PeerParams(virDomainPtr domain, const char *dconnuri, @@ -6621,6 +6726,7 @@ error: return -1; } + /* * Not for public use. This function is part of the internal * implementation of migration in the remote case. @@ -6671,6 +6777,7 @@ error: return -1; } + /* * Not for public use. This function is part of the internal * implementation of migration in the remote case. @@ -6769,6 +6876,7 @@ error: return -1; } + /* * Not for public use. This function is part of the internal * implementation of migration in the remote case. @@ -6870,6 +6978,7 @@ error: return -1; } + /* * Not for public use. This function is part of the internal * implementation of migration in the remote case. @@ -6979,6 +7088,7 @@ error: return -1; } + /* * Not for public use. This function is part of the internal * implementation of migration in the remote case. @@ -7566,6 +7676,7 @@ error: return -1; } + /** * virConnectGetCapabilities: * @conn: pointer to the hypervisor connection @@ -7605,6 +7716,7 @@ error: return NULL; } + /** * virNodeGetCPUStats: * @conn: pointer to the hypervisor connection. @@ -7659,10 +7771,11 @@ error: * * Returns -1 in case of error, 0 in case of success. */ -int virNodeGetCPUStats(virConnectPtr conn, - int cpuNum, - virNodeCPUStatsPtr params, - int *nparams, unsigned int flags) +int +virNodeGetCPUStats(virConnectPtr conn, + int cpuNum, + virNodeCPUStatsPtr params, + int *nparams, unsigned int flags) { VIR_DEBUG("conn=%p, cpuNum=%d, params=%p, nparams=%d, flags=%x", conn, cpuNum, params, nparams ? *nparams : -1, flags); @@ -7698,6 +7811,7 @@ error: return -1; } + /** * virNodeGetMemoryStats: * @conn: pointer to the hypervisor connection. @@ -7748,10 +7862,11 @@ error: * * Returns -1 in case of error, 0 in case of success. */ -int virNodeGetMemoryStats(virConnectPtr conn, - int cellNum, - virNodeMemoryStatsPtr params, - int *nparams, unsigned int flags) +int +virNodeGetMemoryStats(virConnectPtr conn, + int cellNum, + virNodeMemoryStatsPtr params, + int *nparams, unsigned int flags) { VIR_DEBUG("conn=%p, cellNum=%d, params=%p, nparams=%d, flags=%x", conn, cellNum, params, nparams ? *nparams : -1, flags); @@ -7787,6 +7902,7 @@ error: return -1; } + /** * virNodeGetFreeMemory: * @conn: pointer to the hypervisor connection @@ -7825,6 +7941,7 @@ error: return 0; } + /** * virNodeSuspendForDuration: * @conn: pointer to the hypervisor connection @@ -7885,6 +8002,7 @@ error: return -1; } + /* * virNodeGetMemoryParameters: * @conn: pointer to the hypervisor connection @@ -7949,6 +8067,7 @@ error: return -1; } + /* * virNodeSetMemoryParameters: * @conn: pointer to the hypervisor connection @@ -8015,6 +8134,7 @@ error: return -1; } + /** * virDomainGetSchedulerType: * @domain: pointer to domain object @@ -8114,6 +8234,7 @@ error: return -1; } + /** * virDomainGetSchedulerParametersFlags: * @domain: pointer to domain object @@ -8197,6 +8318,7 @@ error: return -1; } + /** * virDomainSetSchedulerParameters: * @domain: pointer to domain object @@ -8392,6 +8514,7 @@ error: return -1; } + /** * virDomainBlockStatsFlags: * @dom: pointer to domain object @@ -8429,11 +8552,12 @@ error: * * Returns -1 in case of error, 0 in case of success. */ -int virDomainBlockStatsFlags(virDomainPtr dom, - const char *disk, - virTypedParameterPtr params, - int *nparams, - unsigned int flags) +int +virDomainBlockStatsFlags(virDomainPtr dom, + const char *disk, + virTypedParameterPtr params, + int *nparams, + unsigned int flags) { virConnectPtr conn; @@ -8538,7 +8662,8 @@ error: return -1; } - /** + +/** * virDomainSetInterfaceParameters: * @domain: pointer to domain object * @device: the interface name or mac address @@ -8605,7 +8730,8 @@ error: return -1; } - /** + +/** * virDomainGetInterfaceParameters: * @domain: pointer to domain object * @device: the interface name or mac address @@ -8631,7 +8757,6 @@ error: * * Returns -1 in case of error, 0 in case of success. */ - int virDomainGetInterfaceParameters(virDomainPtr domain, const char *device, @@ -8677,6 +8802,7 @@ error: return -1; } + /** * virDomainMemoryStats: * @dom: pointer to the domain object @@ -8709,8 +8835,9 @@ error: * * Returns: The number of stats provided or -1 in case of failure. */ -int virDomainMemoryStats(virDomainPtr dom, virDomainMemoryStatPtr stats, - unsigned int nr_stats, unsigned int flags) +int +virDomainMemoryStats(virDomainPtr dom, virDomainMemoryStatPtr stats, + unsigned int nr_stats, unsigned int flags) { virConnectPtr conn; unsigned long nr_stats_ret = 0; @@ -8748,6 +8875,7 @@ error: return -1; } + /** * virDomainBlockPeek: * @dom: pointer to the domain object @@ -8841,6 +8969,7 @@ error: return -1; } + /** * virDomainBlockResize: * @dom: pointer to the domain object @@ -8868,7 +8997,6 @@ error: * * Returns: 0 in case of success or -1 in case of failure. */ - int virDomainBlockResize(virDomainPtr dom, const char *disk, @@ -8910,6 +9038,7 @@ error: return -1; } + /** * virDomainMemoryPeek: * @dom: pointer to the domain object @@ -9102,7 +9231,8 @@ error: * Returns NULL in case of error, a pointer to the domain otherwise */ virDomainPtr -virDomainDefineXML(virConnectPtr conn, const char *xml) { +virDomainDefineXML(virConnectPtr conn, const char *xml) +{ VIR_DEBUG("conn=%p, xml=%s", conn, xml); virResetLastError(); @@ -9133,6 +9263,7 @@ error: return NULL; } + /** * virDomainUndefine: * @domain: pointer to a defined domain @@ -9149,7 +9280,8 @@ error: * Returns 0 in case of success, -1 in case of error */ int -virDomainUndefine(virDomainPtr domain) { +virDomainUndefine(virDomainPtr domain) +{ virConnectPtr conn; VIR_DOMAIN_DEBUG(domain); @@ -9182,6 +9314,7 @@ error: return -1; } + /** * virDomainUndefineFlags: * @domain: pointer to a defined domain @@ -9279,6 +9412,7 @@ error: return -1; } + /** * virConnectListDefinedDomains: * @conn: pointer to the hypervisor connection @@ -9299,7 +9433,8 @@ error: */ int virConnectListDefinedDomains(virConnectPtr conn, char **const names, - int maxnames) { + int maxnames) +{ VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames); virResetLastError(); @@ -9328,6 +9463,7 @@ error: return -1; } + /** * virConnectListAllDomains: * @conn: Pointer to the hypervisor connection. @@ -9433,6 +9569,7 @@ error: return -1; } + /** * virDomainCreate: * @domain: pointer to a defined domain @@ -9445,7 +9582,8 @@ error: * Returns 0 in case of success, -1 in case of error */ int -virDomainCreate(virDomainPtr domain) { +virDomainCreate(virDomainPtr domain) +{ virConnectPtr conn; VIR_DOMAIN_DEBUG(domain); @@ -9478,6 +9616,7 @@ error: return -1; } + /** * virDomainCreateWithFlags: * @domain: pointer to a defined domain @@ -9512,7 +9651,8 @@ error: * Returns 0 in case of success, -1 in case of error */ int -virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) { +virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) +{ virConnectPtr conn; VIR_DOMAIN_DEBUG(domain, "flags=%x", flags); @@ -9545,6 +9685,7 @@ error: return -1; } + /** * virDomainCreateWithFiles: * @domain: pointer to a defined domain @@ -9626,6 +9767,7 @@ error: return -1; } + /** * virDomainGetAutostart: * @domain: a domain object @@ -9671,6 +9813,7 @@ error: return -1; } + /** * virDomainSetAutostart: * @domain: a domain object @@ -9719,6 +9862,7 @@ error: return -1; } + /** * virDomainInjectNMI: * @domain: pointer to domain object, or NULL for Domain0 @@ -9728,8 +9872,8 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - -int virDomainInjectNMI(virDomainPtr domain, unsigned int flags) +int +virDomainInjectNMI(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; VIR_DOMAIN_DEBUG(domain, "flags=%x", flags); @@ -9763,6 +9907,7 @@ error: return -1; } + /** * virDomainSendKey: * @domain: pointer to domain object, or NULL for Domain0 @@ -9776,13 +9921,13 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - -int virDomainSendKey(virDomainPtr domain, - unsigned int codeset, - unsigned int holdtime, - unsigned int *keycodes, - int nkeycodes, - unsigned int flags) +int +virDomainSendKey(virDomainPtr domain, + unsigned int codeset, + unsigned int holdtime, + unsigned int *keycodes, + int nkeycodes, + unsigned int flags) { virConnectPtr conn; VIR_DOMAIN_DEBUG(domain, "codeset=%u, holdtime=%u, nkeycodes=%u, flags=%x", @@ -9859,10 +10004,11 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ -int virDomainSendProcessSignal(virDomainPtr domain, - long long pid_value, - unsigned int signum, - unsigned int flags) +int +virDomainSendProcessSignal(virDomainPtr domain, + long long pid_value, + unsigned int signum, + unsigned int flags) { virConnectPtr conn; VIR_DOMAIN_DEBUG(domain, "pid=%lld, signum=%u flags=%x", @@ -9921,7 +10067,6 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - int virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) { @@ -9960,6 +10105,7 @@ error: return -1; } + /** * virDomainSetVcpusFlags: * @domain: pointer to domain object, or NULL for Domain0 @@ -9996,7 +10142,6 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - int virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, unsigned int flags) @@ -10049,6 +10194,7 @@ error: return -1; } + /** * virDomainGetVcpusFlags: * @domain: pointer to domain object, or NULL for Domain0 @@ -10077,7 +10223,6 @@ error: * * Returns the number of vCPUs in case of success, -1 in case of failure. */ - int virDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags) { @@ -10119,6 +10264,7 @@ error: return -1; } + /** * virDomainPinVcpu: * @domain: pointer to domain object, or NULL for Domain0 @@ -10186,6 +10332,7 @@ error: return -1; } + /** * virDomainPinVcpuFlags: * @domain: pointer to domain object, or NULL for Domain0 @@ -10264,9 +10411,9 @@ virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu, error: virDispatchError(domain->conn); return -1; - } + /** * virDomainGetVcpuPinInfo: * @domain: pointer to domain object, or NULL for Domain0 @@ -10344,6 +10491,7 @@ error: return -1; } + /** * virDomainPinEmulator: * @domain: pointer to domain object, or NULL for Domain0 @@ -10420,6 +10568,7 @@ error: return -1; } + /** * virDomainGetEmulatorPinInfo: * @domain: pointer to domain object, or NULL for Domain0 @@ -10486,6 +10635,7 @@ error: return -1; } + /** * virDomainGetVcpus: * @domain: pointer to domain object, or NULL for Domain0 @@ -10562,6 +10712,7 @@ error: return -1; } + /** * virDomainGetMaxVcpus: * @domain: pointer to domain object @@ -10606,6 +10757,7 @@ error: return -1; } + /** * virDomainGetSecurityLabel: * @domain: a domain object @@ -10649,6 +10801,7 @@ error: return -1; } + /** * virDomainGetSecurityLabelList: * @domain: a domain object @@ -10792,6 +10945,7 @@ error: return -1; } + /** * virDomainGetMetadata: * @domain: a domain object @@ -10868,6 +11022,7 @@ error: return NULL; } + /** * virNodeGetSecurityModel: * @conn: a connection object @@ -10907,6 +11062,7 @@ error: return -1; } + /** * virDomainAttachDevice: * @domain: pointer to domain object @@ -10959,6 +11115,7 @@ error: return -1; } + /** * virDomainAttachDeviceFlags: * @domain: pointer to domain object @@ -11022,6 +11179,7 @@ error: return -1; } + /** * virDomainDetachDevice: * @domain: pointer to domain object @@ -11070,6 +11228,7 @@ error: return -1; } + /** * virDomainDetachDeviceFlags: * @domain: pointer to domain object @@ -11149,6 +11308,7 @@ error: return -1; } + /** * virDomainUpdateDeviceFlags: * @domain: pointer to domain object @@ -11212,6 +11372,7 @@ error: return -1; } + /** * virNodeGetCellsFreeMemory: * @conn: pointer to the hypervisor connection @@ -11229,7 +11390,6 @@ error: * * Returns the number of entries filled in freeMems, or -1 in case of error. */ - int virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems, int startCell, int maxCells) @@ -11264,6 +11424,7 @@ error: return -1; } + /** * virNetworkGetConnect: * @net: pointer to a network @@ -11293,6 +11454,7 @@ virNetworkGetConnect(virNetworkPtr net) return net->conn; } + /** * virConnectListAllNetworks: * @conn: Pointer to the hypervisor connection. @@ -11399,6 +11561,7 @@ error: return -1; } + /** * virConnectListNetworks: * @conn: pointer to the hypervisor connection @@ -11446,6 +11609,7 @@ error: return -1; } + /** * virConnectNumOfDefinedNetworks: * @conn: pointer to the hypervisor connection @@ -11482,6 +11646,7 @@ error: return -1; } + /** * virConnectListDefinedNetworks: * @conn: pointer to the hypervisor connection @@ -11530,6 +11695,7 @@ error: return -1; } + /** * virNetworkLookupByName: * @conn: pointer to the hypervisor connection @@ -11569,6 +11735,7 @@ error: return NULL; } + /** * virNetworkLookupByUUID: * @conn: pointer to the hypervisor connection @@ -11609,6 +11776,7 @@ error: return NULL; } + /** * virNetworkLookupByUUIDString: * @conn: pointer to the hypervisor connection @@ -11649,6 +11817,7 @@ error: return NULL; } + /** * virNetworkCreateXML: * @conn: pointer to the hypervisor connection @@ -11693,6 +11862,7 @@ error: return NULL; } + /** * virNetworkDefineXML: * @conn: pointer to the hypervisor connection @@ -11735,6 +11905,7 @@ error: return NULL; } + /** * virNetworkUndefine: * @network: pointer to a defined network @@ -11744,7 +11915,8 @@ error: * Returns 0 in case of success, -1 in case of error */ int -virNetworkUndefine(virNetworkPtr network) { +virNetworkUndefine(virNetworkPtr network) +{ virConnectPtr conn; VIR_DEBUG("network=%p", network); @@ -11776,6 +11948,7 @@ error: return -1; } + /** * virNetworkUpdate: * @network: pointer to a defined network @@ -11838,6 +12011,7 @@ error: return -1; } + /** * virNetworkCreate: * @network: pointer to a defined network @@ -11881,6 +12055,7 @@ error: return -1; } + /** * virNetworkDestroy: * @network: a network object @@ -11927,6 +12102,7 @@ error: return -1; } + /** * virNetworkFree: * @network: a network object @@ -11952,6 +12128,7 @@ virNetworkFree(virNetworkPtr network) return 0; } + /** * virNetworkRef: * @network: the network to hold a reference on @@ -11982,6 +12159,7 @@ virNetworkRef(virNetworkPtr network) return 0; } + /** * virNetworkGetName: * @network: a network object @@ -12006,6 +12184,7 @@ virNetworkGetName(virNetworkPtr network) return network->name; } + /** * virNetworkGetUUID: * @network: a network object @@ -12038,6 +12217,7 @@ error: return -1; } + /** * virNetworkGetUUIDString: * @network: a network object @@ -12074,6 +12254,7 @@ error: return -1; } + /** * virNetworkGetXMLDesc: * @network: a network object @@ -12121,6 +12302,7 @@ error: return NULL; } + /** * virNetworkGetBridgeName: * @network: a network object @@ -12162,6 +12344,7 @@ error: return NULL; } + /** * virNetworkGetAutostart: * @network: a network object @@ -12206,6 +12389,7 @@ error: return -1; } + /** * virNetworkSetAutostart: * @network: a network object @@ -12253,6 +12437,7 @@ error: return -1; } + /** * virInterfaceGetConnect: * @iface: pointer to an interface @@ -12282,6 +12467,7 @@ virInterfaceGetConnect(virInterfacePtr iface) return iface->conn; } + /** * virConnectListAllInterfaces: * @conn: Pointer to the hypervisor connection. @@ -12343,6 +12529,7 @@ error: return -1; } + /** * virConnectNumOfInterfaces: * @conn: pointer to the hypervisor connection @@ -12379,6 +12566,7 @@ error: return -1; } + /** * virConnectListInterfaces: * @conn: pointer to the hypervisor connection @@ -12427,6 +12615,7 @@ error: return -1; } + /** * virConnectNumOfDefinedInterfaces: * @conn: pointer to the hypervisor connection @@ -12463,6 +12652,7 @@ error: return -1; } + /** * virConnectListDefinedInterfaces: * @conn: pointer to the hypervisor connection @@ -12513,6 +12703,7 @@ error: return -1; } + /** * virInterfaceLookupByName: * @conn: pointer to the hypervisor connection @@ -12552,6 +12743,7 @@ error: return NULL; } + /** * virInterfaceLookupByMACString: * @conn: pointer to the hypervisor connection @@ -12591,6 +12783,7 @@ error: return NULL; } + /** * virInterfaceGetName: * @iface: an interface object @@ -12615,6 +12808,7 @@ virInterfaceGetName(virInterfacePtr iface) return iface->name; } + /** * virInterfaceGetMACString: * @iface: an interface object @@ -12641,6 +12835,7 @@ virInterfaceGetMACString(virInterfacePtr iface) return iface->mac; } + /** * virInterfaceGetXMLDesc: * @iface: an interface object @@ -12690,6 +12885,7 @@ error: return NULL; } + /** * virInterfaceDefineXML: * @conn: pointer to the hypervisor connection @@ -12743,6 +12939,7 @@ error: return NULL; } + /** * virInterfaceUndefine: * @iface: pointer to a defined interface @@ -12763,7 +12960,8 @@ error: * Returns 0 in case of success, -1 in case of error */ int -virInterfaceUndefine(virInterfacePtr iface) { +virInterfaceUndefine(virInterfacePtr iface) +{ virConnectPtr conn; VIR_DEBUG("iface=%p", iface); @@ -12795,6 +12993,7 @@ error: return -1; } + /** * virInterfaceCreate: * @iface: pointer to a defined interface @@ -12843,6 +13042,7 @@ error: return -1; } + /** * virInterfaceDestroy: * @iface: an interface object @@ -12896,6 +13096,7 @@ error: return -1; } + /** * virInterfaceRef: * @iface: the interface to hold a reference on @@ -12926,6 +13127,7 @@ virInterfaceRef(virInterfacePtr iface) return 0; } + /** * virInterfaceFree: * @iface: an interface object @@ -12951,6 +13153,7 @@ virInterfaceFree(virInterfacePtr iface) return 0; } + /** * virInterfaceChangeBegin: * @conn: pointer to hypervisor connection @@ -13001,6 +13204,7 @@ error: return -1; } + /** * virInterfaceChangeCommit: * @conn: pointer to hypervisor connection @@ -13048,6 +13252,7 @@ error: return -1; } + /** * virInterfaceChangeRollback: * @conn: pointer to hypervisor connection @@ -13126,6 +13331,7 @@ virStoragePoolGetConnect(virStoragePoolPtr pool) return pool->conn; } + /** * virConnectListAllStoragePools: * @conn: Pointer to the hypervisor connection. @@ -13210,6 +13416,7 @@ error: return -1; } + /** * virConnectNumOfStoragePools: * @conn: pointer to hypervisor connection @@ -13246,6 +13453,7 @@ error: return -1; } + /** * virConnectListStoragePools: * @conn: pointer to hypervisor connection @@ -13603,6 +13811,7 @@ error: return NULL; } + /** * virStoragePoolCreateXML: * @conn: pointer to hypervisor connection @@ -13651,6 +13860,7 @@ error: return NULL; } + /** * virStoragePoolDefineXML: * @conn: pointer to hypervisor connection @@ -13697,6 +13907,7 @@ error: return NULL; } + /** * virStoragePoolBuild: * @pool: pointer to storage pool @@ -13880,6 +14091,7 @@ error: return -1; } + /** * virStoragePoolDelete: * @pool: pointer to storage pool @@ -13985,6 +14197,7 @@ virStoragePoolRef(virStoragePoolPtr pool) return 0; } + /** * virStoragePoolRefresh: * @pool: pointer to storage pool @@ -14090,6 +14303,7 @@ error: return -1; } + /** * virStoragePoolGetUUIDString: * @pool: pointer to storage pool @@ -14307,6 +14521,7 @@ error: return -1; } + /** * virStoragePoolListAllVolumes: * @pool: Pointer to storage pool @@ -14356,6 +14571,7 @@ error: return -1; } + /** * virStoragePoolNumOfVolumes: * @pool: pointer to storage pool @@ -14512,7 +14728,6 @@ error: } - /** * virStorageVolLookupByKey: * @conn: pointer to hypervisor connection @@ -14554,6 +14769,7 @@ error: return NULL; } + /** * virStorageVolLookupByPath: * @conn: pointer to hypervisor connection @@ -15050,6 +15266,7 @@ error: return -1; } + /** * virStorageVolFree: * @vol: pointer to storage volume @@ -15106,6 +15323,7 @@ virStorageVolRef(virStorageVolPtr vol) return 0; } + /** * virStorageVolGetInfo: * @vol: pointer to storage volume @@ -15239,6 +15457,7 @@ error: return NULL; } + /** * virStorageVolResize: * @vol: pointer to storage volume @@ -15320,6 +15539,7 @@ error: return -1; } + /** * virNodeNumOfDevices: * @conn: pointer to the hypervisor connection @@ -15361,6 +15581,7 @@ error: return -1; } + /** * virConnectListAllNodeDevices: * @conn: Pointer to the hypervisor connection. @@ -15434,6 +15655,7 @@ error: return -1; } + /** * virNodeListDevices: * @conn: pointer to the hypervisor connection @@ -15495,7 +15717,8 @@ error: * * Returns a virNodeDevicePtr if found, NULL otherwise. */ -virNodeDevicePtr virNodeDeviceLookupByName(virConnectPtr conn, const char *name) +virNodeDevicePtr +virNodeDeviceLookupByName(virConnectPtr conn, const char *name) { VIR_DEBUG("conn=%p, name=%p", conn, name); @@ -15524,6 +15747,7 @@ error: return NULL; } + /** * virNodeDeviceLookupSCSIHostByWWN: * @conn: pointer to the hypervisor connection @@ -15571,6 +15795,7 @@ error: return NULL; } + /** * virNodeDeviceGetXMLDesc: * @dev: pointer to the node device @@ -15630,6 +15855,7 @@ const char *virNodeDeviceGetName(virNodeDevicePtr dev) return dev->name; } + /** * virNodeDeviceGetParent: * @dev: the device @@ -15663,6 +15889,7 @@ const char *virNodeDeviceGetParent(virNodeDevicePtr dev) return dev->parent; } + /** * virNodeDeviceNumOfCaps: * @dev: the device @@ -15671,7 +15898,8 @@ const char *virNodeDeviceGetParent(virNodeDevicePtr dev) * * Returns the number of capabilities supported by the device. */ -int virNodeDeviceNumOfCaps(virNodeDevicePtr dev) +int +virNodeDeviceNumOfCaps(virNodeDevicePtr dev) { VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL); @@ -15698,6 +15926,7 @@ error: return -1; } + /** * virNodeDeviceListCaps: * @dev: the device @@ -15708,9 +15937,10 @@ error: * * Returns the number of capability names listed in @names. */ -int virNodeDeviceListCaps(virNodeDevicePtr dev, - char **const names, - int maxnames) +int +virNodeDeviceListCaps(virNodeDevicePtr dev, + char **const names, + int maxnames) { VIR_DEBUG("dev=%p, conn=%p, names=%p, maxnames=%d", dev, dev ? dev->conn : NULL, names, maxnames); @@ -15751,7 +15981,8 @@ error: * * Returns the 0 for success, -1 for error. */ -int virNodeDeviceFree(virNodeDevicePtr dev) +int +virNodeDeviceFree(virNodeDevicePtr dev) { VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL); @@ -15797,6 +16028,7 @@ virNodeDeviceRef(virNodeDevicePtr dev) return 0; } + /** * virNodeDeviceDettach: * @dev: pointer to the node device @@ -15854,6 +16086,7 @@ error: return -1; } + /** * virNodeDeviceDetachFlags: * @dev: pointer to the node device @@ -15918,6 +16151,7 @@ error: return -1; } + /** * virNodeDeviceReAttach: * @dev: pointer to the node device @@ -15966,6 +16200,7 @@ error: return -1; } + /** * virNodeDeviceReset: * @dev: pointer to the node device @@ -16169,6 +16404,7 @@ error: return -1; } + /** * virConnectDomainEventDeregister: * @conn: pointer to the connection @@ -16212,6 +16448,7 @@ error: return -1; } + /** * virSecretGetConnect: * @secret: A virSecret secret @@ -16239,6 +16476,7 @@ virSecretGetConnect(virSecretPtr secret) return secret->conn; } + /** * virConnectNumOfSecrets: * @conn: virConnect connection @@ -16277,6 +16515,7 @@ error: return -1; } + /** * virConnectListAllSecrets: * @conn: Pointer to the hypervisor connection. @@ -16344,6 +16583,7 @@ error: return -1; } + /** * virConnectListSecrets: * @conn: virConnect connection @@ -16385,6 +16625,7 @@ error: return -1; } + /** * virSecretLookupByUUID: * @conn: pointer to the hypervisor connection @@ -16426,6 +16667,7 @@ error: return NULL; } + /** * virSecretLookupByUUIDString: * @conn: pointer to the hypervisor connection @@ -16562,6 +16804,7 @@ error: return NULL; } + /** * virSecretGetUUID: * @secret: A virSecret secret @@ -16595,6 +16838,7 @@ error: return -1; } + /** * virSecretGetUUIDString: * @secret: a secret object @@ -16631,6 +16875,7 @@ error: return -1; } + /** * virSecretGetUsageType: * @secret: a secret object @@ -16659,6 +16904,7 @@ virSecretGetUsageType(virSecretPtr secret) return secret->usageType; } + /** * virSecretGetUsageID: * @secret: a secret object @@ -16733,6 +16979,7 @@ error: return NULL; } + /** * virSecretSetValue: * @secret: A virSecret secret @@ -16783,6 +17030,7 @@ error: return -1; } + /** * virSecretGetValue: * @secret: A virSecret connection @@ -16831,6 +17079,7 @@ error: return NULL; } + /** * virSecretUndefine: * @secret: A virSecret secret @@ -16876,6 +17125,7 @@ error: return -1; } + /** * virSecretRef: * @secret: the secret to hold a reference on @@ -16905,6 +17155,7 @@ virSecretRef(virSecretPtr secret) return 0; } + /** * virSecretFree: * @secret: pointer to a secret @@ -17064,9 +17315,10 @@ virStreamRef(virStreamPtr stream) * Returns -2 if the outgoing transmit buffers are full & * the stream is marked as non-blocking. */ -int virStreamSend(virStreamPtr stream, - const char *data, - size_t nbytes) +int +virStreamSend(virStreamPtr stream, + const char *data, + size_t nbytes) { VIR_DEBUG("stream=%p, data=%p, nbytes=%zi", stream, data, nbytes); @@ -17161,9 +17413,10 @@ error: * Returns -2 if there is no data pending to be read & the * stream is marked as non-blocking. */ -int virStreamRecv(virStreamPtr stream, - char *data, - size_t nbytes) +int +virStreamRecv(virStreamPtr stream, + char *data, + size_t nbytes) { VIR_DEBUG("stream=%p, data=%p, nbytes=%zi", stream, data, nbytes); @@ -17236,9 +17489,10 @@ error: * having been called, so the caller need only call * virStreamFree() */ -int virStreamSendAll(virStreamPtr stream, - virStreamSourceFunc handler, - void *opaque) +int +virStreamSendAll(virStreamPtr stream, + virStreamSourceFunc handler, + void *opaque) { char *bytes = NULL; int want = 1024*64; @@ -17333,9 +17587,10 @@ cleanup: * having been called, so the caller need only call * virStreamFree() */ -int virStreamRecvAll(virStreamPtr stream, - virStreamSinkFunc handler, - void *opaque) +int +virStreamRecvAll(virStreamPtr stream, + virStreamSinkFunc handler, + void *opaque) { char *bytes = NULL; int want = 1024*64; @@ -17406,11 +17661,12 @@ cleanup: * * Returns 0 on success, -1 upon error */ -int virStreamEventAddCallback(virStreamPtr stream, - int events, - virStreamEventCallback cb, - void *opaque, - virFreeCallback ff) +int +virStreamEventAddCallback(virStreamPtr stream, + int events, + virStreamEventCallback cb, + void *opaque, + virFreeCallback ff) { VIR_DEBUG("stream=%p, events=%d, cb=%p, opaque=%p, ff=%p", stream, events, cb, opaque, ff); @@ -17451,8 +17707,9 @@ error: * * Returns 0 on success, -1 if no callback is registered */ -int virStreamEventUpdateCallback(virStreamPtr stream, - int events) +int +virStreamEventUpdateCallback(virStreamPtr stream, + int events) { VIR_DEBUG("stream=%p, events=%d", stream, events); @@ -17480,6 +17737,7 @@ error: return -1; } + /** * virStreamEventRemoveCallback: * @stream: pointer to the stream object @@ -17488,7 +17746,8 @@ error: * * Returns 0 on success, -1 on error */ -int virStreamEventRemoveCallback(virStreamPtr stream) +int +virStreamEventRemoveCallback(virStreamPtr stream) { VIR_DEBUG("stream=%p", stream); @@ -17516,6 +17775,7 @@ error: return -1; } + /** * virStreamFinish: * @stream: pointer to the stream object @@ -17531,7 +17791,8 @@ error: * * Returns 0 on success, -1 upon error */ -int virStreamFinish(virStreamPtr stream) +int +virStreamFinish(virStreamPtr stream) { VIR_DEBUG("stream=%p", stream); @@ -17559,6 +17820,7 @@ error: return -1; } + /** * virStreamAbort: * @stream: pointer to the stream object @@ -17572,7 +17834,8 @@ error: * * Returns 0 on success, -1 upon error */ -int virStreamAbort(virStreamPtr stream) +int +virStreamAbort(virStreamPtr stream) { VIR_DEBUG("stream=%p", stream); @@ -17604,6 +17867,7 @@ error: return -1; } + /** * virStreamFree: * @stream: pointer to the stream object @@ -17618,7 +17882,8 @@ error: * * Returns 0 upon success, or -1 on error */ -int virStreamFree(virStreamPtr stream) +int +virStreamFree(virStreamPtr stream) { VIR_DEBUG("stream=%p", stream); @@ -17645,7 +17910,8 @@ int virStreamFree(virStreamPtr stream) * * Returns 1 if running, 0 if inactive, -1 on error */ -int virDomainIsActive(virDomainPtr dom) +int +virDomainIsActive(virDomainPtr dom) { VIR_DEBUG("dom=%p", dom); @@ -17670,6 +17936,7 @@ error: return -1; } + /** * virDomainIsPersistent: * @dom: pointer to the domain object @@ -17679,7 +17946,8 @@ error: * * Returns 1 if persistent, 0 if transient, -1 on error */ -int virDomainIsPersistent(virDomainPtr dom) +int +virDomainIsPersistent(virDomainPtr dom) { VIR_DOMAIN_DEBUG(dom); @@ -17704,6 +17972,7 @@ error: return -1; } + /** * virDomainIsUpdated: * @dom: pointer to the domain object @@ -17712,7 +17981,8 @@ error: * * Returns 1 if updated, 0 if not, -1 on error */ -int virDomainIsUpdated(virDomainPtr dom) +int +virDomainIsUpdated(virDomainPtr dom) { VIR_DOMAIN_DEBUG(dom); @@ -17737,6 +18007,7 @@ error: return -1; } + /** * virNetworkIsActive: * @net: pointer to the network object @@ -17745,7 +18016,8 @@ error: * * Returns 1 if running, 0 if inactive, -1 on error */ -int virNetworkIsActive(virNetworkPtr net) +int +virNetworkIsActive(virNetworkPtr net) { VIR_DEBUG("net=%p", net); @@ -17780,7 +18052,8 @@ error: * * Returns 1 if persistent, 0 if transient, -1 on error */ -int virNetworkIsPersistent(virNetworkPtr net) +int +virNetworkIsPersistent(virNetworkPtr net) { VIR_DEBUG("net=%p", net); @@ -17814,7 +18087,8 @@ error: * * Returns 1 if running, 0 if inactive, -1 on error */ -int virStoragePoolIsActive(virStoragePoolPtr pool) +int +virStoragePoolIsActive(virStoragePoolPtr pool) { VIR_DEBUG("pool=%p", pool); @@ -17849,7 +18123,8 @@ error: * * Returns 1 if persistent, 0 if transient, -1 on error */ -int virStoragePoolIsPersistent(virStoragePoolPtr pool) +int +virStoragePoolIsPersistent(virStoragePoolPtr pool) { VIR_DEBUG("pool=%p", pool); @@ -17875,7 +18150,6 @@ error: } - /** * virConnectNumOfNWFilters: * @conn: pointer to the hypervisor connection @@ -17912,6 +18186,7 @@ error: return -1; } + /** * virConnectListAllNWFilters: * @conn: Pointer to the hypervisor connection. @@ -17963,6 +18238,7 @@ error: return -1; } + /** * virConnectListNWFilters: * @conn: pointer to the hypervisor connection @@ -18044,6 +18320,7 @@ error: return NULL; } + /** * virNWFilterLookupByUUID: * @conn: pointer to the hypervisor connection @@ -18083,6 +18360,7 @@ error: return NULL; } + /** * virNWFilterLookupByUUIDString: * @conn: pointer to the hypervisor connection @@ -18122,6 +18400,7 @@ error: return NULL; } + /** * virNWFilterFree: * @nwfilter: a nwfilter object @@ -18148,6 +18427,7 @@ virNWFilterFree(virNWFilterPtr nwfilter) return 0; } + /** * virNWFilterGetName: * @nwfilter: a nwfilter object @@ -18172,6 +18452,7 @@ virNWFilterGetName(virNWFilterPtr nwfilter) return nwfilter->name; } + /** * virNWFilterGetUUID: * @nwfilter: a nwfilter object @@ -18204,6 +18485,7 @@ error: return -1; } + /** * virNWFilterGetUUIDString: * @nwfilter: a nwfilter object @@ -18414,7 +18696,8 @@ virNWFilterRef(virNWFilterPtr nwfilter) * * Returns 1 if running, 0 if inactive, -1 on error */ -int virInterfaceIsActive(virInterfacePtr iface) +int +virInterfaceIsActive(virInterfacePtr iface) { VIR_DEBUG("iface=%p", iface); @@ -18448,7 +18731,8 @@ error: * * Returns 1 if encrypted, 0 if not encrypted, -1 on error */ -int virConnectIsEncrypted(virConnectPtr conn) +int +virConnectIsEncrypted(virConnectPtr conn) { VIR_DEBUG("conn=%p", conn); @@ -18473,6 +18757,7 @@ error: return -1; } + /** * virConnectIsSecure: * @conn: pointer to the connection object @@ -18485,7 +18770,8 @@ error: * * Returns 1 if secure, 0 if not secure, -1 on error */ -int virConnectIsSecure(virConnectPtr conn) +int +virConnectIsSecure(virConnectPtr conn) { VIR_DEBUG("conn=%p", conn); @@ -18866,6 +19152,7 @@ error: return -1; } + /** * virDomainMigrateGetCompressionCache: * @domain: a domain object @@ -18911,6 +19198,7 @@ error: return -1; } + /** * virDomainMigrateSetCompressionCache: * @domain: a domain object @@ -18961,6 +19249,7 @@ error: return -1; } + /** * virDomainMigrateSetMaxSpeed: * @domain: a domain object @@ -19008,6 +19297,7 @@ error: return -1; } + /** * virDomainMigrateGetMaxSpeed: * @domain: a domain object @@ -19057,6 +19347,7 @@ error: return -1; } + /** * virConnectDomainEventRegisterAny: * @conn: pointer to the connection @@ -19137,6 +19428,7 @@ error: return -1; } + /** * virConnectDomainEventDeregisterAny: * @conn: pointer to the connection @@ -19176,6 +19468,7 @@ error: return -1; } + /** * virConnectNetworkEventRegisterAny: * @conn: pointer to the connection @@ -19260,6 +19553,7 @@ error: return -1; } + /** * virConnectNetworkEventDeregisterAny: * @conn: pointer to the connection @@ -19301,6 +19595,7 @@ error: return -1; } + /** * virDomainManagedSave: * @dom: pointer to the domain @@ -19330,7 +19625,8 @@ error: * * Returns 0 in case of success or -1 in case of failure */ -int virDomainManagedSave(virDomainPtr dom, unsigned int flags) +int +virDomainManagedSave(virDomainPtr dom, unsigned int flags) { virConnectPtr conn; @@ -19373,6 +19669,7 @@ error: return -1; } + /** * virDomainHasManagedSaveImage: * @dom: pointer to the domain @@ -19385,7 +19682,8 @@ error: * Returns 0 if no image is present, 1 if an image is present, and * -1 in case of error */ -int virDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) +int +virDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) { virConnectPtr conn; @@ -19417,6 +19715,7 @@ error: return -1; } + /** * virDomainManagedSaveRemove: * @dom: pointer to the domain @@ -19426,7 +19725,8 @@ error: * * Returns 0 in case of success, and -1 in case of error */ -int virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) +int +virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) { virConnectPtr conn; @@ -19462,6 +19762,7 @@ error: return -1; } + /** * virDomainSnapshotGetName: * @snapshot: a snapshot object @@ -19487,6 +19788,7 @@ virDomainSnapshotGetName(virDomainSnapshotPtr snapshot) return snapshot->name; } + /** * virDomainSnapshotGetDomain: * @snapshot: a snapshot object @@ -19516,6 +19818,7 @@ virDomainSnapshotGetDomain(virDomainSnapshotPtr snapshot) return snapshot->domain; } + /** * virDomainSnapshotGetConnect: * @snapshot: a snapshot object @@ -19545,6 +19848,7 @@ virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot) return snapshot->domain->conn; } + /** * virDomainSnapshotCreateXML: * @domain: a domain object @@ -19704,6 +20008,7 @@ error: return NULL; } + /** * virDomainSnapshotGetXMLDesc: * @snapshot: a domain snapshot object @@ -19757,6 +20062,7 @@ error: return NULL; } + /** * virDomainSnapshotNum: * @domain: a domain object @@ -19827,6 +20133,7 @@ error: return -1; } + /** * virDomainSnapshotListNames: * @domain: a domain object @@ -19918,6 +20225,7 @@ error: return -1; } + /** * virDomainListAllSnapshots: * @domain: a domain object @@ -20003,6 +20311,7 @@ error: return -1; } + /** * virDomainSnapshotNumChildren: * @snapshot: a domain snapshot object @@ -20074,6 +20383,7 @@ error: return -1; } + /** * virDomainSnapshotListChildrenNames: * @snapshot: a domain snapshot object @@ -20171,6 +20481,7 @@ error: return -1; } + /** * virDomainSnapshotListAllChildren: * @snapshot: a domain snapshot object @@ -20259,6 +20570,7 @@ error: return -1; } + /** * virDomainSnapshotLookupByName: * @domain: a domain object @@ -20306,6 +20618,7 @@ error: return NULL; } + /** * virDomainHasCurrentSnapshot: * @domain: pointer to the domain object @@ -20345,6 +20658,7 @@ error: return -1; } + /** * virDomainSnapshotCurrent: * @domain: a domain object @@ -20388,6 +20702,7 @@ error: return NULL; } + /** * virDomainSnapshotGetParent: * @snapshot: a snapshot object @@ -20432,6 +20747,7 @@ error: return NULL; } + /** * virDomainSnapshotIsCurrent: * @snapshot: a snapshot object @@ -20442,8 +20758,9 @@ error: * * Returns 1 if current, 0 if not current, or -1 on error. */ -int virDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, - unsigned int flags) +int +virDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, + unsigned int flags) { virConnectPtr conn; @@ -20474,6 +20791,7 @@ error: return -1; } + /** * virDomainSnapshotHasMetadata: * @snapshot: a snapshot object @@ -20485,8 +20803,9 @@ error: * Returns 1 if the snapshot has metadata, 0 if the snapshot exists without * help from libvirt, or -1 on error. */ -int virDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, - unsigned int flags) +int +virDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, + unsigned int flags) { virConnectPtr conn; @@ -20517,6 +20836,7 @@ error: return -1; } + /** * virDomainRevertToSnapshot: * @snapshot: a domain snapshot object @@ -20604,6 +20924,7 @@ error: return -1; } + /** * virDomainSnapshotDelete: * @snapshot: a domain snapshot object @@ -20673,6 +20994,7 @@ error: return -1; } + /** * virDomainSnapshotRef: * @snapshot: the snapshot to hold a reference on @@ -20704,6 +21026,7 @@ virDomainSnapshotRef(virDomainSnapshotPtr snapshot) return 0; } + /** * virDomainSnapshotFree: * @snapshot: a domain snapshot object @@ -20730,6 +21053,7 @@ virDomainSnapshotFree(virDomainSnapshotPtr snapshot) return 0; } + /** * virDomainOpenConsole: * @dom: a domain object @@ -20760,10 +21084,11 @@ virDomainSnapshotFree(virDomainSnapshotPtr snapshot) * * Returns 0 if the console was opened, -1 on error */ -int virDomainOpenConsole(virDomainPtr dom, - const char *dev_name, - virStreamPtr st, - unsigned int flags) +int +virDomainOpenConsole(virDomainPtr dom, + const char *dev_name, + virStreamPtr st, + unsigned int flags) { virConnectPtr conn; @@ -20799,6 +21124,7 @@ error: return -1; } + /** * virDomainOpenChannel: * @dom: a domain object @@ -20821,10 +21147,11 @@ error: * * Returns 0 if the channel was opened, -1 on error */ -int virDomainOpenChannel(virDomainPtr dom, - const char *name, - virStreamPtr st, - unsigned int flags) +int +virDomainOpenChannel(virDomainPtr dom, + const char *name, + virStreamPtr st, + unsigned int flags) { virConnectPtr conn; @@ -20860,6 +21187,7 @@ error: return -1; } + /** * virDomainBlockJobAbort: * @dom: pointer to domain object @@ -20900,8 +21228,9 @@ error: * * Returns -1 in case of failure, 0 when successful. */ -int virDomainBlockJobAbort(virDomainPtr dom, const char *disk, - unsigned int flags) +int +virDomainBlockJobAbort(virDomainPtr dom, const char *disk, + unsigned int flags) { virConnectPtr conn; @@ -20938,6 +21267,7 @@ error: return -1; } + /** * virDomainGetBlockJobInfo: * @dom: pointer to domain object @@ -20957,8 +21287,9 @@ error: * * Returns -1 in case of failure, 0 when nothing found, 1 when info was found. */ -int virDomainGetBlockJobInfo(virDomainPtr dom, const char *disk, - virDomainBlockJobInfoPtr info, unsigned int flags) +int +virDomainGetBlockJobInfo(virDomainPtr dom, const char *disk, + virDomainBlockJobInfoPtr info, unsigned int flags) { virConnectPtr conn; @@ -20993,6 +21324,7 @@ error: return -1; } + /** * virDomainBlockJobSetSpeed: * @dom: pointer to domain object @@ -21012,8 +21344,9 @@ error: * * Returns -1 in case of failure, 0 when successful. */ -int virDomainBlockJobSetSpeed(virDomainPtr dom, const char *disk, - unsigned long bandwidth, unsigned int flags) +int +virDomainBlockJobSetSpeed(virDomainPtr dom, const char *disk, + unsigned long bandwidth, unsigned int flags) { virConnectPtr conn; @@ -21051,6 +21384,7 @@ error: return -1; } + /** * virDomainBlockPull: * @dom: pointer to domain object @@ -21084,8 +21418,9 @@ error: * * Returns 0 if the operation has started, -1 on failure. */ -int virDomainBlockPull(virDomainPtr dom, const char *disk, - unsigned long bandwidth, unsigned int flags) +int +virDomainBlockPull(virDomainPtr dom, const char *disk, + unsigned long bandwidth, unsigned int flags) { virConnectPtr conn; @@ -21202,9 +21537,10 @@ error: * * Returns 0 if the operation has started, -1 on failure. */ -int virDomainBlockRebase(virDomainPtr dom, const char *disk, - const char *base, unsigned long bandwidth, - unsigned int flags) +int +virDomainBlockRebase(virDomainPtr dom, const char *disk, + const char *base, unsigned long bandwidth, + unsigned int flags) { virConnectPtr conn; @@ -21320,9 +21656,10 @@ error: * * Returns 0 if the operation has started, -1 on failure. */ -int virDomainBlockCommit(virDomainPtr dom, const char *disk, - const char *base, const char *top, - unsigned long bandwidth, unsigned int flags) +int +virDomainBlockCommit(virDomainPtr dom, const char *disk, + const char *base, const char *top, + unsigned long bandwidth, unsigned int flags) { virConnectPtr conn; @@ -21386,10 +21723,11 @@ error: * * Returns 0 on success, -1 on failure */ -int virDomainOpenGraphics(virDomainPtr dom, - unsigned int idx, - int fd, - unsigned int flags) +int +virDomainOpenGraphics(virDomainPtr dom, + unsigned int idx, + int fd, + unsigned int flags) { struct stat sb; VIR_DOMAIN_DEBUG(dom, "idx=%u, fd=%d, flags=%x", @@ -21470,9 +21808,10 @@ error: * Returns -1 on error, 0 on success, 1 when remote party doesn't support * keepalive messages. */ -int virConnectSetKeepAlive(virConnectPtr conn, - int interval, - unsigned int count) +int +virConnectSetKeepAlive(virConnectPtr conn, + int interval, + unsigned int count) { int ret = -1; @@ -21500,6 +21839,7 @@ error: return -1; } + /** * virConnectIsAlive: * @conn: pointer to the connection object @@ -21511,7 +21851,8 @@ error: * * Returns 1 if alive, 0 if dead, -1 on error */ -int virConnectIsAlive(virConnectPtr conn) +int +virConnectIsAlive(virConnectPtr conn) { VIR_DEBUG("conn=%p", conn); @@ -21560,10 +21901,11 @@ error: * * Returns 0 on success, -1 on error */ -int virConnectRegisterCloseCallback(virConnectPtr conn, - virConnectCloseFunc cb, - void *opaque, - virFreeCallback freecb) +int +virConnectRegisterCloseCallback(virConnectPtr conn, + virConnectCloseFunc cb, + void *opaque, + virFreeCallback freecb) { VIR_DEBUG("conn=%p", conn); @@ -21606,6 +21948,7 @@ error: return -1; } + /** * virConnectUnregisterCloseCallback: * @conn: pointer to connection object @@ -21619,8 +21962,9 @@ error: * * Returns 0 on success, -1 on error */ -int virConnectUnregisterCloseCallback(virConnectPtr conn, - virConnectCloseFunc cb) +int +virConnectUnregisterCloseCallback(virConnectPtr conn, + virConnectCloseFunc cb) { VIR_DEBUG("conn=%p", conn); @@ -21661,6 +22005,7 @@ error: return -1; } + /** * virDomainSetBlockIoTune: * @dom: pointer to domain object @@ -21681,11 +22026,12 @@ error: * * Returns -1 in case of error, 0 in case of success. */ -int virDomainSetBlockIoTune(virDomainPtr dom, - const char *disk, - virTypedParameterPtr params, - int nparams, - unsigned int flags) +int +virDomainSetBlockIoTune(virDomainPtr dom, + const char *disk, + virTypedParameterPtr params, + int nparams, + unsigned int flags) { virConnectPtr conn; @@ -21730,6 +22076,7 @@ error: return -1; } + /** * virDomainGetBlockIoTune: * @dom: pointer to domain object @@ -21763,11 +22110,12 @@ error: * * Returns -1 in case of error, 0 in case of success. */ -int virDomainGetBlockIoTune(virDomainPtr dom, - const char *disk, - virTypedParameterPtr params, - int *nparams, - unsigned int flags) +int +virDomainGetBlockIoTune(virDomainPtr dom, + const char *disk, + virTypedParameterPtr params, + int *nparams, + unsigned int flags) { virConnectPtr conn; @@ -21818,6 +22166,7 @@ error: return -1; } + /** * virDomainGetCPUStats: * @domain: domain to query @@ -21892,12 +22241,13 @@ error: * @ncpus is too large). The caller is responsible for freeing any * returned string parameters. */ -int virDomainGetCPUStats(virDomainPtr domain, - virTypedParameterPtr params, - unsigned int nparams, - int start_cpu, - unsigned int ncpus, - unsigned int flags) +int +virDomainGetCPUStats(virDomainPtr domain, + virTypedParameterPtr params, + unsigned int nparams, + int start_cpu, + unsigned int ncpus, + unsigned int flags) { virConnectPtr conn; @@ -21963,6 +22313,7 @@ error: return -1; } + /** * virDomainGetDiskErrors: * @dom: a domain object @@ -22028,6 +22379,7 @@ error: return -1; } + /** * virDomainGetHostname: * @domain: a domain object @@ -22073,6 +22425,7 @@ error: return NULL; } + /** * virNodeGetCPUMap: * @conn: pointer to the hypervisor connection @@ -22124,6 +22477,7 @@ error: return -1; } + /** * virDomainFSTrim: * @dom: a domain object -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
Preliminary cleanups to make search-and-replace easier in later patches.
* src/libvirt.c: Uniform two spaces between functions, return type and open brace on separate line, and label in column 1.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 718 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 536 insertions(+), 182 deletions(-)
Well -someone- was busy during the holidays :-) Figured this was as good as place as any to start... I did peek at the "final product", but since this first patch was about consistency of function decls, parameters, etc. I figured I'd do a summary here rather than trying to find each in the lines below. In general it's very mechanical, but there were a few misses: 1. The following didn't follow the rules exactly: $ grep "^char \*" libvirt.c | grep -v "^char \*$" char *virConnectDomainXMLFromNative(virConnectPtr conn, char *virConnectDomainXMLToNative(virConnectPtr conn, char *virNodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags) $ grep "^const char \*" libvirt.c | grep -v "^const char \*$" const char *virNodeDeviceGetName(virNodeDevicePtr dev) const char *virNodeDeviceGetParent(virNodeDevicePtr dev) I did the same for 'unsigned char *', 'int', 'unsigned int', 'unsigned long', and various 'vir*Ptr' return types (Domain, Connect, Network, Interface, StoragePool, StorageVol, NodeDevice, Secret, Stream, NWFilter, and DomainSnapshot). I think I covered all the various return types I saw, but I supposed I could have missed a few... FWIW: Initially seen by searching backwords for "/**" for each entry point comment intro 2. virDomain{Get|Set}BlkioParameters have an extra space on the 2nd/3rd lines of the argument list, e.g.: virDomainSetBlkioParameters(virDomainPtr domain, virTypedParameterPtr params, int nparams, unsigned int flags) and virDomainGetBlkioParameters(virDomainPtr domain, virTypedParameterPtr params, int *nparams, unsigned int flags) 3. virDomainRestoreFlags() - line longer than 80 chars - that is all on one line: virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml, unsigned int flags) 4. And the copyright will I know be fixed the next time you touch the file... ACK with the changes John
diff --git a/src/libvirt.c b/src/libvirt.c index 6aaa3a4..8066b7c 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -128,7 +128,9 @@ static int virStateDriverTabCount = 0;
#if defined(POLKIT_AUTH) -static int virConnectAuthGainPolkit(const char *privilege) { +static int +virConnectAuthGainPolkit(const char *privilege) +{ virCommandPtr cmd; int status; int ret = -1; @@ -148,9 +150,12 @@ cleanup: } #endif
-static int virConnectAuthCallbackDefault(virConnectCredentialPtr cred, - unsigned int ncred, - void *cbdata ATTRIBUTE_UNUSED) { + +static int +virConnectAuthCallbackDefault(virConnectCredentialPtr cred, + unsigned int ncred, + void *cbdata ATTRIBUTE_UNUSED) +{ size_t i;
for (i = 0; i < ncred; i++) { @@ -225,6 +230,7 @@ static int virConnectAuthCallbackDefault(virConnectCredentialPtr cred, return 0; }
+ /* Don't typically want VIR_CRED_USERNAME. It enables you to authenticate * as one user, and act as another. It just results in annoying * prompts for the username twice & is very rarely what you want @@ -273,7 +279,8 @@ winsock_init(void)
#ifdef WITH_GNUTLS_GCRYPT -static int virTLSMutexInit(void **priv) +static int +virTLSMutexInit(void **priv) { virMutexPtr lock = NULL;
@@ -289,7 +296,9 @@ static int virTLSMutexInit(void **priv) return 0; }
-static int virTLSMutexDestroy(void **priv) + +static int +virTLSMutexDestroy(void **priv) { virMutexPtr lock = *priv; virMutexDestroy(lock); @@ -297,20 +306,25 @@ static int virTLSMutexDestroy(void **priv) return 0; }
-static int virTLSMutexLock(void **priv) + +static int +virTLSMutexLock(void **priv) { virMutexPtr lock = *priv; virMutexLock(lock); return 0; }
-static int virTLSMutexUnlock(void **priv) + +static int +virTLSMutexUnlock(void **priv) { virMutexPtr lock = *priv; virMutexUnlock(lock); return 0; }
+ static struct gcry_thread_cbs virTLSThreadImpl = { /* GCRY_THREAD_OPTION_VERSION was added in gcrypt 1.4.2 */ # ifdef GCRY_THREAD_OPTION_VERSION @@ -506,6 +520,7 @@ error: virGlobalError = true; }
+ /** * virInitialize: * @@ -532,6 +547,7 @@ virInitialize(void) return 0; }
+ #ifdef WIN32 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID ignore); @@ -566,6 +582,7 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, } #endif
+ #define virLibConnError(code, ...) \ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) @@ -628,6 +645,7 @@ virRegisterNetworkDriver(virNetworkDriverPtr driver) return virNetworkDriverTabCount++; }
+ /** * virRegisterInterfaceDriver: * @driver: pointer to an interface driver block @@ -655,6 +673,7 @@ virRegisterInterfaceDriver(virInterfaceDriverPtr driver) return virInterfaceDriverTabCount++; }
+ /** * virRegisterStorageDriver: * @driver: pointer to a storage driver block @@ -682,6 +701,7 @@ virRegisterStorageDriver(virStorageDriverPtr driver) return virStorageDriverTabCount++; }
+ /** * virRegisterNodeDeviceDriver: * @driver: pointer to a device monitor block @@ -709,6 +729,7 @@ virRegisterNodeDeviceDriver(virNodeDeviceDriverPtr driver) return virNodeDeviceDriverTabCount++; }
+ /** * virRegisterSecretDriver: * @driver: pointer to a secret driver block @@ -736,6 +757,7 @@ virRegisterSecretDriver(virSecretDriverPtr driver) return virSecretDriverTabCount++; }
+ /** * virRegisterNWFilterDriver: * @driver: pointer to a network filter driver block @@ -793,6 +815,7 @@ virRegisterDriver(virDriverPtr driver) return virDriverTabCount++; }
+ #ifdef WITH_LIBVIRTD /** * virRegisterStateDriver: @@ -818,6 +841,7 @@ virRegisterStateDriver(virStateDriverPtr driver) return virStateDriverTabCount++; }
+ /** * virStateInitialize: * @privileged: set to true if running with root privilege, false otherwise @@ -832,9 +856,10 @@ virRegisterStateDriver(virStateDriverPtr driver) * * Returns 0 if all succeed, -1 upon any failure. */ -int virStateInitialize(bool privileged, - virStateInhibitCallback callback, - void *opaque) +int +virStateInitialize(bool privileged, + virStateInhibitCallback callback, + void *opaque) { size_t i;
@@ -867,6 +892,7 @@ int virStateInitialize(bool privileged, return 0; }
+ /** * virStateCleanup: * @@ -874,7 +900,9 @@ int virStateInitialize(bool privileged, * * Returns 0 if all succeed, -1 upon any failure. */ -int virStateCleanup(void) { +int +virStateCleanup(void) +{ size_t i; int ret = 0;
@@ -886,6 +914,7 @@ int virStateCleanup(void) { return ret; }
+ /** * virStateReload: * @@ -893,7 +922,9 @@ int virStateCleanup(void) { * * Returns 0 if all succeed, -1 upon any failure. */ -int virStateReload(void) { +int +virStateReload(void) +{ size_t i; int ret = 0;
@@ -905,6 +936,7 @@ int virStateReload(void) { return ret; }
+ /** * virStateStop: * @@ -912,7 +944,9 @@ int virStateReload(void) { * * Returns 0 if successful, -1 on failure */ -int virStateStop(void) { +int +virStateStop(void) +{ size_t i; int ret = 0;
@@ -923,9 +957,7 @@ int virStateStop(void) { } return ret; } - -#endif - +#endif /* WITH_LIBVIRTD */
/** @@ -971,6 +1003,7 @@ error: return -1; }
+ static char * virConnectGetConfigFilePath(void) { @@ -995,6 +1028,7 @@ virConnectGetConfigFilePath(void) return path; }
+ static int virConnectGetConfigFile(virConfPtr *conf) { @@ -1024,8 +1058,10 @@ cleanup:
#define URI_ALIAS_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"
+ static int -virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, char **uri) +virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, + char **uri) { virConfValuePtr entry; size_t alias_len; @@ -1078,6 +1114,7 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, char * return 0; }
+ static int virConnectOpenResolveURIAlias(virConfPtr conf, const char *alias, char **uri) @@ -1121,6 +1158,7 @@ cleanup: return ret; }
+ static virConnectPtr do_open(const char *name, virConnectAuthPtr auth, @@ -1372,6 +1410,7 @@ failed: return NULL; }
+ /** * virConnectOpen: * @name: (optional) URI of the hypervisor @@ -1414,6 +1453,7 @@ error: return NULL; }
+ /** * virConnectOpenReadOnly: * @name: (optional) URI of the hypervisor @@ -1449,6 +1489,7 @@ error: return NULL; }
+ /** * virConnectOpenAuth: * @name: (optional) URI of the hypervisor @@ -1488,6 +1529,7 @@ error: return NULL; }
+ /** * virConnectClose: * @conn: pointer to the hypervisor connection @@ -1538,6 +1580,7 @@ error: return ret; }
+ /** * virConnectRef: * @conn: the connection to hold a reference on @@ -1568,6 +1611,7 @@ virConnectRef(virConnectPtr conn) return 0; }
+ /* * Not for public use. This function is part of the internal * implementation of driver features in the remote case. @@ -1597,6 +1641,7 @@ virConnectSupportsFeature(virConnectPtr conn, int feature) return ret; }
+ /** * virConnectGetType: * @conn: pointer to the hypervisor connection @@ -1633,6 +1678,7 @@ virConnectGetType(virConnectPtr conn) return conn->driver->name; }
+ /** * virConnectGetVersion: * @conn: pointer to the hypervisor connection @@ -1675,6 +1721,7 @@ error: return -1; }
+ /** * virConnectGetLibVersion: * @conn: pointer to the hypervisor connection @@ -1717,6 +1764,7 @@ error: return ret; }
+ /** * virConnectGetHostname: * @conn: pointer to a hypervisor connection @@ -1757,6 +1805,7 @@ error: return NULL; }
+ /** * virConnectGetURI: * @conn: pointer to a hypervisor connection @@ -1796,6 +1845,7 @@ error: return NULL; }
+ /** * virConnectGetSysinfo: * @conn: pointer to a hypervisor connection @@ -1836,6 +1886,7 @@ error: return NULL; }
+ /** * virConnectGetMaxVcpus: * @conn: pointer to the hypervisor connection @@ -1874,6 +1925,7 @@ error: return -1; }
+ /** * virConnectListDomains: * @conn: pointer to the hypervisor connection @@ -1920,6 +1972,7 @@ error: return -1; }
+ /** * virConnectNumOfDomains: * @conn: pointer to the hypervisor connection @@ -1954,6 +2007,7 @@ error: return -1; }
+ /** * virDomainGetConnect: * @dom: pointer to a domain @@ -1983,6 +2037,7 @@ virDomainGetConnect(virDomainPtr dom) return dom->conn; }
+ /** * virDomainCreateXML: * @conn: pointer to the hypervisor connection @@ -2042,6 +2097,7 @@ error: return NULL; }
+ /** * virDomainCreateXMLWithFiles: * @conn: pointer to the hypervisor connection @@ -2115,6 +2171,7 @@ error: return NULL; }
+ /** * virDomainCreateLinux: * @conn: pointer to the hypervisor connection @@ -2134,6 +2191,7 @@ virDomainCreateLinux(virConnectPtr conn, const char *xmlDesc, return virDomainCreateXML(conn, xmlDesc, flags); }
+ /** * virDomainLookupByID: * @conn: pointer to the hypervisor connection @@ -2175,6 +2233,7 @@ error: return NULL; }
+ /** * virDomainLookupByUUID: * @conn: pointer to the hypervisor connection @@ -2214,6 +2273,7 @@ error: return NULL; }
+ /** * virDomainLookupByUUIDString: * @conn: pointer to the hypervisor connection @@ -2253,6 +2313,7 @@ error: return NULL; }
+ /** * virDomainLookupByName: * @conn: pointer to the hypervisor connection @@ -2292,6 +2353,7 @@ error: return NULL; }
+ /** * virDomainDestroy: * @domain: a domain object @@ -2352,6 +2414,7 @@ error: return -1; }
+ /** * virDomainDestroyFlags: * @domain: a domain object @@ -2418,6 +2481,7 @@ error: return -1; }
+ /** * virDomainFree: * @domain: a domain object @@ -2443,6 +2507,7 @@ virDomainFree(virDomainPtr domain) return 0; }
+ /** * virDomainRef: * @domain: the domain to hold a reference on @@ -2525,6 +2590,7 @@ error: return -1; }
+ /** * virDomainResume: * @domain: a domain object @@ -2573,6 +2639,7 @@ error: return -1; }
+ /** * virDomainPMSuspendForDuration: * @dom: a domain object @@ -2641,6 +2708,7 @@ error: return -1; }
+ /** * virDomainPMWakeup: * @dom: a domain object @@ -2691,6 +2759,7 @@ error: return -1; }
+ /** * virDomainSave: * @domain: a domain object @@ -2755,6 +2824,7 @@ error: return -1; }
+ /** * virDomainSaveFlags: * @domain: a domain object @@ -2850,6 +2920,7 @@ error: return -1; }
+ /** * virDomainRestore: * @conn: pointer to the hypervisor connection @@ -2906,6 +2977,7 @@ error: return -1; }
+ /** * virDomainRestoreFlags: * @conn: pointer to the hypervisor connection @@ -2989,6 +3061,7 @@ error: return -1; }
+ /** * virDomainSaveImageGetXMLDesc: * @conn: pointer to the hypervisor connection @@ -3057,6 +3130,7 @@ error: return NULL; }
+ /** * virDomainSaveImageDefineXML: * @conn: pointer to the hypervisor connection @@ -3138,6 +3212,7 @@ error: return -1; }
+ /** * virDomainCoreDump: * @domain: a domain object @@ -3229,6 +3304,7 @@ error: return -1; }
+ /** * virDomainScreenshot: * @domain: a domain object @@ -3294,6 +3370,7 @@ error: return NULL; }
+ /** * virDomainShutdown: * @domain: a domain object @@ -3350,6 +3427,7 @@ error: return -1; }
+ /** * virDomainShutdownFlags: * @domain: a domain object @@ -3413,6 +3491,7 @@ error: return -1; }
+ /** * virDomainReboot: * @domain: a domain object @@ -3477,6 +3556,7 @@ error: return -1; }
+ /** * virDomainReset: * @domain: a domain object @@ -3527,6 +3607,7 @@ error: return -1; }
+ /** * virDomainGetName: * @domain: a domain object @@ -3551,6 +3632,7 @@ virDomainGetName(virDomainPtr domain) return domain->name; }
+ /** * virDomainGetUUID: * @domain: a domain object @@ -3579,6 +3661,7 @@ virDomainGetUUID(virDomainPtr domain, unsigned char *uuid) return 0; }
+ /** * virDomainGetUUIDString: * @domain: a domain object @@ -3616,6 +3699,7 @@ error: return -1; }
+ /** * virDomainGetID: * @domain: a domain object @@ -3639,6 +3723,7 @@ virDomainGetID(virDomainPtr domain) return domain->id; }
+ /** * virDomainGetOSType: * @domain: a domain object @@ -3680,6 +3765,7 @@ error: return NULL; }
+ /** * virDomainGetMaxMemory: * @domain: a domain object or NULL @@ -3728,6 +3814,7 @@ error: return 0; }
+ /** * virDomainSetMaxMemory: * @domain: a domain object or NULL @@ -3781,6 +3868,7 @@ error: return -1; }
+ /** * virDomainSetMemory: * @domain: a domain object or NULL @@ -3833,6 +3921,7 @@ error: return -1; }
+ /** * virDomainSetMemoryFlags: * @domain: a domain object or NULL @@ -3858,7 +3947,6 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - int virDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, unsigned int flags) @@ -3898,6 +3986,7 @@ error: return -1; }
+ /** * virDomainSetMemoryStatsPeriod: * @domain: a domain object or NULL @@ -3920,7 +4009,6 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - int virDomainSetMemoryStatsPeriod(virDomainPtr domain, int period, unsigned int flags) @@ -3962,6 +4050,7 @@ error: return -1; }
+ /* Helper function called to validate incoming client array on any * interface that sets typed parameters in the hypervisor. */ static int @@ -4003,6 +4092,7 @@ virTypedParameterValidateSet(virConnectPtr conn, return 0; }
+ /** * virDomainSetMemoryParameters: * @domain: pointer to domain object @@ -4061,6 +4151,7 @@ error: return -1; }
+ /** * virDomainGetMemoryParameters: * @domain: pointer to domain object @@ -4146,6 +4237,7 @@ error: return -1; }
+ /** * virDomainSetNumaParameters: * @domain: pointer to domain object @@ -4204,6 +4296,7 @@ error: return -1; }
+ /** * virDomainGetNumaParameters: * @domain: pointer to domain object @@ -4230,7 +4323,6 @@ error: * * Returns -1 in case of error, 0 in case of success. */ - int virDomainGetNumaParameters(virDomainPtr domain, virTypedParameterPtr params, @@ -4274,6 +4366,7 @@ error: return -1; }
+ /** * virDomainSetBlkioParameters: * @domain: pointer to domain object @@ -4332,6 +4425,7 @@ error: return -1; }
+ /** * virDomainGetBlkioParameters: * @domain: pointer to domain object @@ -4408,6 +4502,7 @@ error: return -1; }
+ /** * virDomainGetInfo: * @domain: a domain object @@ -4454,6 +4549,7 @@ error: return -1; }
+ /** * virDomainGetState: * @domain: a domain object @@ -4503,6 +4599,7 @@ error: return -1; }
+ /** * virDomainGetControlInfo: * @domain: a domain object @@ -4548,6 +4645,7 @@ error: return -1; }
+ /** * virDomainGetXMLDesc: * @domain: a domain object @@ -4607,6 +4705,7 @@ error: return NULL; }
+ /** * virConnectDomainXMLFromNative: * @conn: a connection object @@ -4662,6 +4761,7 @@ error: return NULL; }
+ /** * virConnectDomainXMLToNative: * @conn: a connection object @@ -4802,12 +4902,13 @@ virDomainMigrateVersion1(virDomainPtr domain, else ddomain = virDomainLookupByName(dconn, dname);
- done: +done: VIR_FREE(uri_out); VIR_FREE(cookie); return ddomain; }
+ /* * Sequence v2: * @@ -4933,7 +5034,7 @@ finish: ddomain = dconn->driver->domainMigrateFinish2 (dconn, dname, cookie, cookielen, uri, destflags, cancelled);
- done: +done: if (orig_err) { virSetError(orig_err); virFreeError(orig_err); @@ -5228,7 +5329,7 @@ confirm: } }
- done: +done: if (orig_err) { virSetError(orig_err); virFreeError(orig_err); @@ -5241,6 +5342,7 @@ confirm: return ddomain; }
+ static virDomainPtr virDomainMigrateVersion3(virDomainPtr domain, virConnectPtr dconn, @@ -5254,6 +5356,7 @@ virDomainMigrateVersion3(virDomainPtr domain, bandwidth, NULL, 0, false, flags); }
+ static virDomainPtr virDomainMigrateVersion3Params(virDomainPtr domain, virConnectPtr dconn, @@ -5266,20 +5369,20 @@ virDomainMigrateVersion3Params(virDomainPtr domain, }
- /* - * In normal migration, the libvirt client co-ordinates communication - * between the 2 libvirtd instances on source & dest hosts. - * - * In this peer-2-peer migration alternative, the libvirt client - * only talks to the source libvirtd instance. The source libvirtd - * then opens its own connection to the destination and co-ordinates - * migration itself. - * - * If useParams is true, params and nparams contain migration parameters and - * we know it's safe to call the API which supports extensible parameters. - * Otherwise, we have to use xmlin, dname, uri, and bandwidth and pass them - * to the old-style APIs. - */ +/* + * In normal migration, the libvirt client co-ordinates communication + * between the 2 libvirtd instances on source & dest hosts. + * + * In this peer-2-peer migration alternative, the libvirt client + * only talks to the source libvirtd instance. The source libvirtd + * then opens its own connection to the destination and co-ordinates + * migration itself. + * + * If useParams is true, params and nparams contain migration parameters and + * we know it's safe to call the API which supports extensible parameters. + * Otherwise, we have to use xmlin, dname, uri, and bandwidth and pass them + * to the old-style APIs. + */ static int virDomainMigratePeer2PeerFull(virDomainPtr domain, const char *dconnuri, @@ -5349,6 +5452,7 @@ virDomainMigratePeer2PeerFull(virDomainPtr domain, } }
+ static int virDomainMigratePeer2Peer(virDomainPtr domain, const char *xmlin, @@ -5362,6 +5466,7 @@ virDomainMigratePeer2Peer(virDomainPtr domain, bandwidth, NULL, 0, false, flags); }
+ static int virDomainMigratePeer2PeerParams(virDomainPtr domain, const char *dconnuri, @@ -6621,6 +6726,7 @@ error: return -1; }
+ /* * Not for public use. This function is part of the internal * implementation of migration in the remote case. @@ -6671,6 +6777,7 @@ error: return -1; }
+ /* * Not for public use. This function is part of the internal * implementation of migration in the remote case. @@ -6769,6 +6876,7 @@ error: return -1; }
+ /* * Not for public use. This function is part of the internal * implementation of migration in the remote case. @@ -6870,6 +6978,7 @@ error: return -1; }
+ /* * Not for public use. This function is part of the internal * implementation of migration in the remote case. @@ -6979,6 +7088,7 @@ error: return -1; }
+ /* * Not for public use. This function is part of the internal * implementation of migration in the remote case. @@ -7566,6 +7676,7 @@ error: return -1; }
+ /** * virConnectGetCapabilities: * @conn: pointer to the hypervisor connection @@ -7605,6 +7716,7 @@ error: return NULL; }
+ /** * virNodeGetCPUStats: * @conn: pointer to the hypervisor connection. @@ -7659,10 +7771,11 @@ error: * * Returns -1 in case of error, 0 in case of success. */ -int virNodeGetCPUStats(virConnectPtr conn, - int cpuNum, - virNodeCPUStatsPtr params, - int *nparams, unsigned int flags) +int +virNodeGetCPUStats(virConnectPtr conn, + int cpuNum, + virNodeCPUStatsPtr params, + int *nparams, unsigned int flags) { VIR_DEBUG("conn=%p, cpuNum=%d, params=%p, nparams=%d, flags=%x", conn, cpuNum, params, nparams ? *nparams : -1, flags); @@ -7698,6 +7811,7 @@ error: return -1; }
+ /** * virNodeGetMemoryStats: * @conn: pointer to the hypervisor connection. @@ -7748,10 +7862,11 @@ error: * * Returns -1 in case of error, 0 in case of success. */ -int virNodeGetMemoryStats(virConnectPtr conn, - int cellNum, - virNodeMemoryStatsPtr params, - int *nparams, unsigned int flags) +int +virNodeGetMemoryStats(virConnectPtr conn, + int cellNum, + virNodeMemoryStatsPtr params, + int *nparams, unsigned int flags) { VIR_DEBUG("conn=%p, cellNum=%d, params=%p, nparams=%d, flags=%x", conn, cellNum, params, nparams ? *nparams : -1, flags); @@ -7787,6 +7902,7 @@ error: return -1; }
+ /** * virNodeGetFreeMemory: * @conn: pointer to the hypervisor connection @@ -7825,6 +7941,7 @@ error: return 0; }
+ /** * virNodeSuspendForDuration: * @conn: pointer to the hypervisor connection @@ -7885,6 +8002,7 @@ error: return -1; }
+ /* * virNodeGetMemoryParameters: * @conn: pointer to the hypervisor connection @@ -7949,6 +8067,7 @@ error: return -1; }
+ /* * virNodeSetMemoryParameters: * @conn: pointer to the hypervisor connection @@ -8015,6 +8134,7 @@ error: return -1; }
+ /** * virDomainGetSchedulerType: * @domain: pointer to domain object @@ -8114,6 +8234,7 @@ error: return -1; }
+ /** * virDomainGetSchedulerParametersFlags: * @domain: pointer to domain object @@ -8197,6 +8318,7 @@ error: return -1; }
+ /** * virDomainSetSchedulerParameters: * @domain: pointer to domain object @@ -8392,6 +8514,7 @@ error: return -1; }
+ /** * virDomainBlockStatsFlags: * @dom: pointer to domain object @@ -8429,11 +8552,12 @@ error: * * Returns -1 in case of error, 0 in case of success. */ -int virDomainBlockStatsFlags(virDomainPtr dom, - const char *disk, - virTypedParameterPtr params, - int *nparams, - unsigned int flags) +int +virDomainBlockStatsFlags(virDomainPtr dom, + const char *disk, + virTypedParameterPtr params, + int *nparams, + unsigned int flags) { virConnectPtr conn;
@@ -8538,7 +8662,8 @@ error: return -1; }
- /** + +/** * virDomainSetInterfaceParameters: * @domain: pointer to domain object * @device: the interface name or mac address @@ -8605,7 +8730,8 @@ error: return -1; }
- /** + +/** * virDomainGetInterfaceParameters: * @domain: pointer to domain object * @device: the interface name or mac address @@ -8631,7 +8757,6 @@ error: * * Returns -1 in case of error, 0 in case of success. */ - int virDomainGetInterfaceParameters(virDomainPtr domain, const char *device, @@ -8677,6 +8802,7 @@ error: return -1; }
+ /** * virDomainMemoryStats: * @dom: pointer to the domain object @@ -8709,8 +8835,9 @@ error: * * Returns: The number of stats provided or -1 in case of failure. */ -int virDomainMemoryStats(virDomainPtr dom, virDomainMemoryStatPtr stats, - unsigned int nr_stats, unsigned int flags) +int +virDomainMemoryStats(virDomainPtr dom, virDomainMemoryStatPtr stats, + unsigned int nr_stats, unsigned int flags) { virConnectPtr conn; unsigned long nr_stats_ret = 0; @@ -8748,6 +8875,7 @@ error: return -1; }
+ /** * virDomainBlockPeek: * @dom: pointer to the domain object @@ -8841,6 +8969,7 @@ error: return -1; }
+ /** * virDomainBlockResize: * @dom: pointer to the domain object @@ -8868,7 +8997,6 @@ error: * * Returns: 0 in case of success or -1 in case of failure. */ - int virDomainBlockResize(virDomainPtr dom, const char *disk, @@ -8910,6 +9038,7 @@ error: return -1; }
+ /** * virDomainMemoryPeek: * @dom: pointer to the domain object @@ -9102,7 +9231,8 @@ error: * Returns NULL in case of error, a pointer to the domain otherwise */ virDomainPtr -virDomainDefineXML(virConnectPtr conn, const char *xml) { +virDomainDefineXML(virConnectPtr conn, const char *xml) +{ VIR_DEBUG("conn=%p, xml=%s", conn, xml);
virResetLastError(); @@ -9133,6 +9263,7 @@ error: return NULL; }
+ /** * virDomainUndefine: * @domain: pointer to a defined domain @@ -9149,7 +9280,8 @@ error: * Returns 0 in case of success, -1 in case of error */ int -virDomainUndefine(virDomainPtr domain) { +virDomainUndefine(virDomainPtr domain) +{ virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain); @@ -9182,6 +9314,7 @@ error: return -1; }
+ /** * virDomainUndefineFlags: * @domain: pointer to a defined domain @@ -9279,6 +9412,7 @@ error: return -1; }
+ /** * virConnectListDefinedDomains: * @conn: pointer to the hypervisor connection @@ -9299,7 +9433,8 @@ error: */ int virConnectListDefinedDomains(virConnectPtr conn, char **const names, - int maxnames) { + int maxnames) +{ VIR_DEBUG("conn=%p, names=%p, maxnames=%d", conn, names, maxnames);
virResetLastError(); @@ -9328,6 +9463,7 @@ error: return -1; }
+ /** * virConnectListAllDomains: * @conn: Pointer to the hypervisor connection. @@ -9433,6 +9569,7 @@ error: return -1; }
+ /** * virDomainCreate: * @domain: pointer to a defined domain @@ -9445,7 +9582,8 @@ error: * Returns 0 in case of success, -1 in case of error */ int -virDomainCreate(virDomainPtr domain) { +virDomainCreate(virDomainPtr domain) +{ virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain); @@ -9478,6 +9616,7 @@ error: return -1; }
+ /** * virDomainCreateWithFlags: * @domain: pointer to a defined domain @@ -9512,7 +9651,8 @@ error: * Returns 0 in case of success, -1 in case of error */ int -virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) { +virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) +{ virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain, "flags=%x", flags); @@ -9545,6 +9685,7 @@ error: return -1; }
+ /** * virDomainCreateWithFiles: * @domain: pointer to a defined domain @@ -9626,6 +9767,7 @@ error: return -1; }
+ /** * virDomainGetAutostart: * @domain: a domain object @@ -9671,6 +9813,7 @@ error: return -1; }
+ /** * virDomainSetAutostart: * @domain: a domain object @@ -9719,6 +9862,7 @@ error: return -1; }
+ /** * virDomainInjectNMI: * @domain: pointer to domain object, or NULL for Domain0 @@ -9728,8 +9872,8 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - -int virDomainInjectNMI(virDomainPtr domain, unsigned int flags) +int +virDomainInjectNMI(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; VIR_DOMAIN_DEBUG(domain, "flags=%x", flags); @@ -9763,6 +9907,7 @@ error: return -1; }
+ /** * virDomainSendKey: * @domain: pointer to domain object, or NULL for Domain0 @@ -9776,13 +9921,13 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - -int virDomainSendKey(virDomainPtr domain, - unsigned int codeset, - unsigned int holdtime, - unsigned int *keycodes, - int nkeycodes, - unsigned int flags) +int +virDomainSendKey(virDomainPtr domain, + unsigned int codeset, + unsigned int holdtime, + unsigned int *keycodes, + int nkeycodes, + unsigned int flags) { virConnectPtr conn; VIR_DOMAIN_DEBUG(domain, "codeset=%u, holdtime=%u, nkeycodes=%u, flags=%x", @@ -9859,10 +10004,11 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ -int virDomainSendProcessSignal(virDomainPtr domain, - long long pid_value, - unsigned int signum, - unsigned int flags) +int +virDomainSendProcessSignal(virDomainPtr domain, + long long pid_value, + unsigned int signum, + unsigned int flags) { virConnectPtr conn; VIR_DOMAIN_DEBUG(domain, "pid=%lld, signum=%u flags=%x", @@ -9921,7 +10067,6 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - int virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) { @@ -9960,6 +10105,7 @@ error: return -1; }
+ /** * virDomainSetVcpusFlags: * @domain: pointer to domain object, or NULL for Domain0 @@ -9996,7 +10142,6 @@ error: * * Returns 0 in case of success, -1 in case of failure. */ - int virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, unsigned int flags) @@ -10049,6 +10194,7 @@ error: return -1; }
+ /** * virDomainGetVcpusFlags: * @domain: pointer to domain object, or NULL for Domain0 @@ -10077,7 +10223,6 @@ error: * * Returns the number of vCPUs in case of success, -1 in case of failure. */ - int virDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags) { @@ -10119,6 +10264,7 @@ error: return -1; }
+ /** * virDomainPinVcpu: * @domain: pointer to domain object, or NULL for Domain0 @@ -10186,6 +10332,7 @@ error: return -1; }
+ /** * virDomainPinVcpuFlags: * @domain: pointer to domain object, or NULL for Domain0 @@ -10264,9 +10411,9 @@ virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu, error: virDispatchError(domain->conn); return -1; - }
+ /** * virDomainGetVcpuPinInfo: * @domain: pointer to domain object, or NULL for Domain0 @@ -10344,6 +10491,7 @@ error: return -1; }
+ /** * virDomainPinEmulator: * @domain: pointer to domain object, or NULL for Domain0 @@ -10420,6 +10568,7 @@ error: return -1; }
+ /** * virDomainGetEmulatorPinInfo: * @domain: pointer to domain object, or NULL for Domain0 @@ -10486,6 +10635,7 @@ error: return -1; }
+ /** * virDomainGetVcpus: * @domain: pointer to domain object, or NULL for Domain0 @@ -10562,6 +10712,7 @@ error: return -1; }
+ /** * virDomainGetMaxVcpus: * @domain: pointer to domain object @@ -10606,6 +10757,7 @@ error: return -1; }
+ /** * virDomainGetSecurityLabel: * @domain: a domain object @@ -10649,6 +10801,7 @@ error: return -1; }
+ /** * virDomainGetSecurityLabelList: * @domain: a domain object @@ -10792,6 +10945,7 @@ error: return -1; }
+ /** * virDomainGetMetadata: * @domain: a domain object @@ -10868,6 +11022,7 @@ error: return NULL; }
+ /** * virNodeGetSecurityModel: * @conn: a connection object @@ -10907,6 +11062,7 @@ error: return -1; }
+ /** * virDomainAttachDevice: * @domain: pointer to domain object @@ -10959,6 +11115,7 @@ error: return -1; }
+ /** * virDomainAttachDeviceFlags: * @domain: pointer to domain object @@ -11022,6 +11179,7 @@ error: return -1; }
+ /** * virDomainDetachDevice: * @domain: pointer to domain object @@ -11070,6 +11228,7 @@ error: return -1; }
+ /** * virDomainDetachDeviceFlags: * @domain: pointer to domain object @@ -11149,6 +11308,7 @@ error: return -1; }
+ /** * virDomainUpdateDeviceFlags: * @domain: pointer to domain object @@ -11212,6 +11372,7 @@ error: return -1; }
+ /** * virNodeGetCellsFreeMemory: * @conn: pointer to the hypervisor connection @@ -11229,7 +11390,6 @@ error: * * Returns the number of entries filled in freeMems, or -1 in case of error. */ - int virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems, int startCell, int maxCells) @@ -11264,6 +11424,7 @@ error: return -1; }
+ /** * virNetworkGetConnect: * @net: pointer to a network @@ -11293,6 +11454,7 @@ virNetworkGetConnect(virNetworkPtr net) return net->conn; }
+ /** * virConnectListAllNetworks: * @conn: Pointer to the hypervisor connection. @@ -11399,6 +11561,7 @@ error: return -1; }
+ /** * virConnectListNetworks: * @conn: pointer to the hypervisor connection @@ -11446,6 +11609,7 @@ error: return -1; }
+ /** * virConnectNumOfDefinedNetworks: * @conn: pointer to the hypervisor connection @@ -11482,6 +11646,7 @@ error: return -1; }
+ /** * virConnectListDefinedNetworks: * @conn: pointer to the hypervisor connection @@ -11530,6 +11695,7 @@ error: return -1; }
+ /** * virNetworkLookupByName: * @conn: pointer to the hypervisor connection @@ -11569,6 +11735,7 @@ error: return NULL; }
+ /** * virNetworkLookupByUUID: * @conn: pointer to the hypervisor connection @@ -11609,6 +11776,7 @@ error: return NULL; }
+ /** * virNetworkLookupByUUIDString: * @conn: pointer to the hypervisor connection @@ -11649,6 +11817,7 @@ error: return NULL; }
+ /** * virNetworkCreateXML: * @conn: pointer to the hypervisor connection @@ -11693,6 +11862,7 @@ error: return NULL; }
+ /** * virNetworkDefineXML: * @conn: pointer to the hypervisor connection @@ -11735,6 +11905,7 @@ error: return NULL; }
+ /** * virNetworkUndefine: * @network: pointer to a defined network @@ -11744,7 +11915,8 @@ error: * Returns 0 in case of success, -1 in case of error */ int -virNetworkUndefine(virNetworkPtr network) { +virNetworkUndefine(virNetworkPtr network) +{ virConnectPtr conn; VIR_DEBUG("network=%p", network);
@@ -11776,6 +11948,7 @@ error: return -1; }
+ /** * virNetworkUpdate: * @network: pointer to a defined network @@ -11838,6 +12011,7 @@ error: return -1; }
+ /** * virNetworkCreate: * @network: pointer to a defined network @@ -11881,6 +12055,7 @@ error: return -1; }
+ /** * virNetworkDestroy: * @network: a network object @@ -11927,6 +12102,7 @@ error: return -1; }
+ /** * virNetworkFree: * @network: a network object @@ -11952,6 +12128,7 @@ virNetworkFree(virNetworkPtr network) return 0; }
+ /** * virNetworkRef: * @network: the network to hold a reference on @@ -11982,6 +12159,7 @@ virNetworkRef(virNetworkPtr network) return 0; }
+ /** * virNetworkGetName: * @network: a network object @@ -12006,6 +12184,7 @@ virNetworkGetName(virNetworkPtr network) return network->name; }
+ /** * virNetworkGetUUID: * @network: a network object @@ -12038,6 +12217,7 @@ error: return -1; }
+ /** * virNetworkGetUUIDString: * @network: a network object @@ -12074,6 +12254,7 @@ error: return -1; }
+ /** * virNetworkGetXMLDesc: * @network: a network object @@ -12121,6 +12302,7 @@ error: return NULL; }
+ /** * virNetworkGetBridgeName: * @network: a network object @@ -12162,6 +12344,7 @@ error: return NULL; }
+ /** * virNetworkGetAutostart: * @network: a network object @@ -12206,6 +12389,7 @@ error: return -1; }
+ /** * virNetworkSetAutostart: * @network: a network object @@ -12253,6 +12437,7 @@ error: return -1; }
+ /** * virInterfaceGetConnect: * @iface: pointer to an interface @@ -12282,6 +12467,7 @@ virInterfaceGetConnect(virInterfacePtr iface) return iface->conn; }
+ /** * virConnectListAllInterfaces: * @conn: Pointer to the hypervisor connection. @@ -12343,6 +12529,7 @@ error: return -1; }
+ /** * virConnectNumOfInterfaces: * @conn: pointer to the hypervisor connection @@ -12379,6 +12566,7 @@ error: return -1; }
+ /** * virConnectListInterfaces: * @conn: pointer to the hypervisor connection @@ -12427,6 +12615,7 @@ error: return -1; }
+ /** * virConnectNumOfDefinedInterfaces: * @conn: pointer to the hypervisor connection @@ -12463,6 +12652,7 @@ error: return -1; }
+ /** * virConnectListDefinedInterfaces: * @conn: pointer to the hypervisor connection @@ -12513,6 +12703,7 @@ error: return -1; }
+ /** * virInterfaceLookupByName: * @conn: pointer to the hypervisor connection @@ -12552,6 +12743,7 @@ error: return NULL; }
+ /** * virInterfaceLookupByMACString: * @conn: pointer to the hypervisor connection @@ -12591,6 +12783,7 @@ error: return NULL; }
+ /** * virInterfaceGetName: * @iface: an interface object @@ -12615,6 +12808,7 @@ virInterfaceGetName(virInterfacePtr iface) return iface->name; }
+ /** * virInterfaceGetMACString: * @iface: an interface object @@ -12641,6 +12835,7 @@ virInterfaceGetMACString(virInterfacePtr iface) return iface->mac; }
+ /** * virInterfaceGetXMLDesc: * @iface: an interface object @@ -12690,6 +12885,7 @@ error: return NULL; }
+ /** * virInterfaceDefineXML: * @conn: pointer to the hypervisor connection @@ -12743,6 +12939,7 @@ error: return NULL; }
+ /** * virInterfaceUndefine: * @iface: pointer to a defined interface @@ -12763,7 +12960,8 @@ error: * Returns 0 in case of success, -1 in case of error */ int -virInterfaceUndefine(virInterfacePtr iface) { +virInterfaceUndefine(virInterfacePtr iface) +{ virConnectPtr conn; VIR_DEBUG("iface=%p", iface);
@@ -12795,6 +12993,7 @@ error: return -1; }
+ /** * virInterfaceCreate: * @iface: pointer to a defined interface @@ -12843,6 +13042,7 @@ error: return -1; }
+ /** * virInterfaceDestroy: * @iface: an interface object @@ -12896,6 +13096,7 @@ error: return -1; }
+ /** * virInterfaceRef: * @iface: the interface to hold a reference on @@ -12926,6 +13127,7 @@ virInterfaceRef(virInterfacePtr iface) return 0; }
+ /** * virInterfaceFree: * @iface: an interface object @@ -12951,6 +13153,7 @@ virInterfaceFree(virInterfacePtr iface) return 0; }
+ /** * virInterfaceChangeBegin: * @conn: pointer to hypervisor connection @@ -13001,6 +13204,7 @@ error: return -1; }
+ /** * virInterfaceChangeCommit: * @conn: pointer to hypervisor connection @@ -13048,6 +13252,7 @@ error: return -1; }
+ /** * virInterfaceChangeRollback: * @conn: pointer to hypervisor connection @@ -13126,6 +13331,7 @@ virStoragePoolGetConnect(virStoragePoolPtr pool) return pool->conn; }
+ /** * virConnectListAllStoragePools: * @conn: Pointer to the hypervisor connection. @@ -13210,6 +13416,7 @@ error: return -1; }
+ /** * virConnectNumOfStoragePools: * @conn: pointer to hypervisor connection @@ -13246,6 +13453,7 @@ error: return -1; }
+ /** * virConnectListStoragePools: * @conn: pointer to hypervisor connection @@ -13603,6 +13811,7 @@ error: return NULL; }
+ /** * virStoragePoolCreateXML: * @conn: pointer to hypervisor connection @@ -13651,6 +13860,7 @@ error: return NULL; }
+ /** * virStoragePoolDefineXML: * @conn: pointer to hypervisor connection @@ -13697,6 +13907,7 @@ error: return NULL; }
+ /** * virStoragePoolBuild: * @pool: pointer to storage pool @@ -13880,6 +14091,7 @@ error: return -1; }
+ /** * virStoragePoolDelete: * @pool: pointer to storage pool @@ -13985,6 +14197,7 @@ virStoragePoolRef(virStoragePoolPtr pool) return 0; }
+ /** * virStoragePoolRefresh: * @pool: pointer to storage pool @@ -14090,6 +14303,7 @@ error: return -1; }
+ /** * virStoragePoolGetUUIDString: * @pool: pointer to storage pool @@ -14307,6 +14521,7 @@ error: return -1; }
+ /** * virStoragePoolListAllVolumes: * @pool: Pointer to storage pool @@ -14356,6 +14571,7 @@ error: return -1; }
+ /** * virStoragePoolNumOfVolumes: * @pool: pointer to storage pool @@ -14512,7 +14728,6 @@ error: }
- /** * virStorageVolLookupByKey: * @conn: pointer to hypervisor connection @@ -14554,6 +14769,7 @@ error: return NULL; }
+ /** * virStorageVolLookupByPath: * @conn: pointer to hypervisor connection @@ -15050,6 +15266,7 @@ error: return -1; }
+ /** * virStorageVolFree: * @vol: pointer to storage volume @@ -15106,6 +15323,7 @@ virStorageVolRef(virStorageVolPtr vol) return 0; }
+ /** * virStorageVolGetInfo: * @vol: pointer to storage volume @@ -15239,6 +15457,7 @@ error: return NULL; }
+ /** * virStorageVolResize: * @vol: pointer to storage volume @@ -15320,6 +15539,7 @@ error: return -1; }
+ /** * virNodeNumOfDevices: * @conn: pointer to the hypervisor connection @@ -15361,6 +15581,7 @@ error: return -1; }
+ /** * virConnectListAllNodeDevices: * @conn: Pointer to the hypervisor connection. @@ -15434,6 +15655,7 @@ error: return -1; }
+ /** * virNodeListDevices: * @conn: pointer to the hypervisor connection @@ -15495,7 +15717,8 @@ error: * * Returns a virNodeDevicePtr if found, NULL otherwise. */ -virNodeDevicePtr virNodeDeviceLookupByName(virConnectPtr conn, const char *name) +virNodeDevicePtr +virNodeDeviceLookupByName(virConnectPtr conn, const char *name) { VIR_DEBUG("conn=%p, name=%p", conn, name);
@@ -15524,6 +15747,7 @@ error: return NULL; }
+ /** * virNodeDeviceLookupSCSIHostByWWN: * @conn: pointer to the hypervisor connection @@ -15571,6 +15795,7 @@ error: return NULL; }
+ /** * virNodeDeviceGetXMLDesc: * @dev: pointer to the node device @@ -15630,6 +15855,7 @@ const char *virNodeDeviceGetName(virNodeDevicePtr dev) return dev->name; }
+ /** * virNodeDeviceGetParent: * @dev: the device @@ -15663,6 +15889,7 @@ const char *virNodeDeviceGetParent(virNodeDevicePtr dev) return dev->parent; }
+ /** * virNodeDeviceNumOfCaps: * @dev: the device @@ -15671,7 +15898,8 @@ const char *virNodeDeviceGetParent(virNodeDevicePtr dev) * * Returns the number of capabilities supported by the device. */ -int virNodeDeviceNumOfCaps(virNodeDevicePtr dev) +int +virNodeDeviceNumOfCaps(virNodeDevicePtr dev) { VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
@@ -15698,6 +15926,7 @@ error: return -1; }
+ /** * virNodeDeviceListCaps: * @dev: the device @@ -15708,9 +15937,10 @@ error: * * Returns the number of capability names listed in @names. */ -int virNodeDeviceListCaps(virNodeDevicePtr dev, - char **const names, - int maxnames) +int +virNodeDeviceListCaps(virNodeDevicePtr dev, + char **const names, + int maxnames) { VIR_DEBUG("dev=%p, conn=%p, names=%p, maxnames=%d", dev, dev ? dev->conn : NULL, names, maxnames); @@ -15751,7 +15981,8 @@ error: * * Returns the 0 for success, -1 for error. */ -int virNodeDeviceFree(virNodeDevicePtr dev) +int +virNodeDeviceFree(virNodeDevicePtr dev) { VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL);
@@ -15797,6 +16028,7 @@ virNodeDeviceRef(virNodeDevicePtr dev) return 0; }
+ /** * virNodeDeviceDettach: * @dev: pointer to the node device @@ -15854,6 +16086,7 @@ error: return -1; }
+ /** * virNodeDeviceDetachFlags: * @dev: pointer to the node device @@ -15918,6 +16151,7 @@ error: return -1; }
+ /** * virNodeDeviceReAttach: * @dev: pointer to the node device @@ -15966,6 +16200,7 @@ error: return -1; }
+ /** * virNodeDeviceReset: * @dev: pointer to the node device @@ -16169,6 +16404,7 @@ error: return -1; }
+ /** * virConnectDomainEventDeregister: * @conn: pointer to the connection @@ -16212,6 +16448,7 @@ error: return -1; }
+ /** * virSecretGetConnect: * @secret: A virSecret secret @@ -16239,6 +16476,7 @@ virSecretGetConnect(virSecretPtr secret) return secret->conn; }
+ /** * virConnectNumOfSecrets: * @conn: virConnect connection @@ -16277,6 +16515,7 @@ error: return -1; }
+ /** * virConnectListAllSecrets: * @conn: Pointer to the hypervisor connection. @@ -16344,6 +16583,7 @@ error: return -1; }
+ /** * virConnectListSecrets: * @conn: virConnect connection @@ -16385,6 +16625,7 @@ error: return -1; }
+ /** * virSecretLookupByUUID: * @conn: pointer to the hypervisor connection @@ -16426,6 +16667,7 @@ error: return NULL; }
+ /** * virSecretLookupByUUIDString: * @conn: pointer to the hypervisor connection @@ -16562,6 +16804,7 @@ error: return NULL; }
+ /** * virSecretGetUUID: * @secret: A virSecret secret @@ -16595,6 +16838,7 @@ error: return -1; }
+ /** * virSecretGetUUIDString: * @secret: a secret object @@ -16631,6 +16875,7 @@ error: return -1; }
+ /** * virSecretGetUsageType: * @secret: a secret object @@ -16659,6 +16904,7 @@ virSecretGetUsageType(virSecretPtr secret) return secret->usageType; }
+ /** * virSecretGetUsageID: * @secret: a secret object @@ -16733,6 +16979,7 @@ error: return NULL; }
+ /** * virSecretSetValue: * @secret: A virSecret secret @@ -16783,6 +17030,7 @@ error: return -1; }
+ /** * virSecretGetValue: * @secret: A virSecret connection @@ -16831,6 +17079,7 @@ error: return NULL; }
+ /** * virSecretUndefine: * @secret: A virSecret secret @@ -16876,6 +17125,7 @@ error: return -1; }
+ /** * virSecretRef: * @secret: the secret to hold a reference on @@ -16905,6 +17155,7 @@ virSecretRef(virSecretPtr secret) return 0; }
+ /** * virSecretFree: * @secret: pointer to a secret @@ -17064,9 +17315,10 @@ virStreamRef(virStreamPtr stream) * Returns -2 if the outgoing transmit buffers are full & * the stream is marked as non-blocking. */ -int virStreamSend(virStreamPtr stream, - const char *data, - size_t nbytes) +int +virStreamSend(virStreamPtr stream, + const char *data, + size_t nbytes) { VIR_DEBUG("stream=%p, data=%p, nbytes=%zi", stream, data, nbytes);
@@ -17161,9 +17413,10 @@ error: * Returns -2 if there is no data pending to be read & the * stream is marked as non-blocking. */ -int virStreamRecv(virStreamPtr stream, - char *data, - size_t nbytes) +int +virStreamRecv(virStreamPtr stream, + char *data, + size_t nbytes) { VIR_DEBUG("stream=%p, data=%p, nbytes=%zi", stream, data, nbytes);
@@ -17236,9 +17489,10 @@ error: * having been called, so the caller need only call * virStreamFree() */ -int virStreamSendAll(virStreamPtr stream, - virStreamSourceFunc handler, - void *opaque) +int +virStreamSendAll(virStreamPtr stream, + virStreamSourceFunc handler, + void *opaque) { char *bytes = NULL; int want = 1024*64; @@ -17333,9 +17587,10 @@ cleanup: * having been called, so the caller need only call * virStreamFree() */ -int virStreamRecvAll(virStreamPtr stream, - virStreamSinkFunc handler, - void *opaque) +int +virStreamRecvAll(virStreamPtr stream, + virStreamSinkFunc handler, + void *opaque) { char *bytes = NULL; int want = 1024*64; @@ -17406,11 +17661,12 @@ cleanup: * * Returns 0 on success, -1 upon error */ -int virStreamEventAddCallback(virStreamPtr stream, - int events, - virStreamEventCallback cb, - void *opaque, - virFreeCallback ff) +int +virStreamEventAddCallback(virStreamPtr stream, + int events, + virStreamEventCallback cb, + void *opaque, + virFreeCallback ff) { VIR_DEBUG("stream=%p, events=%d, cb=%p, opaque=%p, ff=%p", stream, events, cb, opaque, ff);
@@ -17451,8 +17707,9 @@ error: * * Returns 0 on success, -1 if no callback is registered */ -int virStreamEventUpdateCallback(virStreamPtr stream, - int events) +int +virStreamEventUpdateCallback(virStreamPtr stream, + int events) { VIR_DEBUG("stream=%p, events=%d", stream, events);
@@ -17480,6 +17737,7 @@ error: return -1; }
+ /** * virStreamEventRemoveCallback: * @stream: pointer to the stream object @@ -17488,7 +17746,8 @@ error: * * Returns 0 on success, -1 on error */ -int virStreamEventRemoveCallback(virStreamPtr stream) +int +virStreamEventRemoveCallback(virStreamPtr stream) { VIR_DEBUG("stream=%p", stream);
@@ -17516,6 +17775,7 @@ error: return -1; }
+ /** * virStreamFinish: * @stream: pointer to the stream object @@ -17531,7 +17791,8 @@ error: * * Returns 0 on success, -1 upon error */ -int virStreamFinish(virStreamPtr stream) +int +virStreamFinish(virStreamPtr stream) { VIR_DEBUG("stream=%p", stream);
@@ -17559,6 +17820,7 @@ error: return -1; }
+ /** * virStreamAbort: * @stream: pointer to the stream object @@ -17572,7 +17834,8 @@ error: * * Returns 0 on success, -1 upon error */ -int virStreamAbort(virStreamPtr stream) +int +virStreamAbort(virStreamPtr stream) { VIR_DEBUG("stream=%p", stream);
@@ -17604,6 +17867,7 @@ error: return -1; }
+ /** * virStreamFree: * @stream: pointer to the stream object @@ -17618,7 +17882,8 @@ error: * * Returns 0 upon success, or -1 on error */ -int virStreamFree(virStreamPtr stream) +int +virStreamFree(virStreamPtr stream) { VIR_DEBUG("stream=%p", stream);
@@ -17645,7 +17910,8 @@ int virStreamFree(virStreamPtr stream) * * Returns 1 if running, 0 if inactive, -1 on error */ -int virDomainIsActive(virDomainPtr dom) +int +virDomainIsActive(virDomainPtr dom) { VIR_DEBUG("dom=%p", dom);
@@ -17670,6 +17936,7 @@ error: return -1; }
+ /** * virDomainIsPersistent: * @dom: pointer to the domain object @@ -17679,7 +17946,8 @@ error: * * Returns 1 if persistent, 0 if transient, -1 on error */ -int virDomainIsPersistent(virDomainPtr dom) +int +virDomainIsPersistent(virDomainPtr dom) { VIR_DOMAIN_DEBUG(dom);
@@ -17704,6 +17972,7 @@ error: return -1; }
+ /** * virDomainIsUpdated: * @dom: pointer to the domain object @@ -17712,7 +17981,8 @@ error: * * Returns 1 if updated, 0 if not, -1 on error */ -int virDomainIsUpdated(virDomainPtr dom) +int +virDomainIsUpdated(virDomainPtr dom) { VIR_DOMAIN_DEBUG(dom);
@@ -17737,6 +18007,7 @@ error: return -1; }
+ /** * virNetworkIsActive: * @net: pointer to the network object @@ -17745,7 +18016,8 @@ error: * * Returns 1 if running, 0 if inactive, -1 on error */ -int virNetworkIsActive(virNetworkPtr net) +int +virNetworkIsActive(virNetworkPtr net) { VIR_DEBUG("net=%p", net);
@@ -17780,7 +18052,8 @@ error: * * Returns 1 if persistent, 0 if transient, -1 on error */ -int virNetworkIsPersistent(virNetworkPtr net) +int +virNetworkIsPersistent(virNetworkPtr net) { VIR_DEBUG("net=%p", net);
@@ -17814,7 +18087,8 @@ error: * * Returns 1 if running, 0 if inactive, -1 on error */ -int virStoragePoolIsActive(virStoragePoolPtr pool) +int +virStoragePoolIsActive(virStoragePoolPtr pool) { VIR_DEBUG("pool=%p", pool);
@@ -17849,7 +18123,8 @@ error: * * Returns 1 if persistent, 0 if transient, -1 on error */ -int virStoragePoolIsPersistent(virStoragePoolPtr pool) +int +virStoragePoolIsPersistent(virStoragePoolPtr pool) { VIR_DEBUG("pool=%p", pool);
@@ -17875,7 +18150,6 @@ error: }
- /** * virConnectNumOfNWFilters: * @conn: pointer to the hypervisor connection @@ -17912,6 +18186,7 @@ error: return -1; }
+ /** * virConnectListAllNWFilters: * @conn: Pointer to the hypervisor connection. @@ -17963,6 +18238,7 @@ error: return -1; }
+ /** * virConnectListNWFilters: * @conn: pointer to the hypervisor connection @@ -18044,6 +18320,7 @@ error: return NULL; }
+ /** * virNWFilterLookupByUUID: * @conn: pointer to the hypervisor connection @@ -18083,6 +18360,7 @@ error: return NULL; }
+ /** * virNWFilterLookupByUUIDString: * @conn: pointer to the hypervisor connection @@ -18122,6 +18400,7 @@ error: return NULL; }
+ /** * virNWFilterFree: * @nwfilter: a nwfilter object @@ -18148,6 +18427,7 @@ virNWFilterFree(virNWFilterPtr nwfilter) return 0; }
+ /** * virNWFilterGetName: * @nwfilter: a nwfilter object @@ -18172,6 +18452,7 @@ virNWFilterGetName(virNWFilterPtr nwfilter) return nwfilter->name; }
+ /** * virNWFilterGetUUID: * @nwfilter: a nwfilter object @@ -18204,6 +18485,7 @@ error: return -1; }
+ /** * virNWFilterGetUUIDString: * @nwfilter: a nwfilter object @@ -18414,7 +18696,8 @@ virNWFilterRef(virNWFilterPtr nwfilter) * * Returns 1 if running, 0 if inactive, -1 on error */ -int virInterfaceIsActive(virInterfacePtr iface) +int +virInterfaceIsActive(virInterfacePtr iface) { VIR_DEBUG("iface=%p", iface);
@@ -18448,7 +18731,8 @@ error: * * Returns 1 if encrypted, 0 if not encrypted, -1 on error */ -int virConnectIsEncrypted(virConnectPtr conn) +int +virConnectIsEncrypted(virConnectPtr conn) { VIR_DEBUG("conn=%p", conn);
@@ -18473,6 +18757,7 @@ error: return -1; }
+ /** * virConnectIsSecure: * @conn: pointer to the connection object @@ -18485,7 +18770,8 @@ error: * * Returns 1 if secure, 0 if not secure, -1 on error */ -int virConnectIsSecure(virConnectPtr conn) +int +virConnectIsSecure(virConnectPtr conn) { VIR_DEBUG("conn=%p", conn);
@@ -18866,6 +19152,7 @@ error: return -1; }
+ /** * virDomainMigrateGetCompressionCache: * @domain: a domain object @@ -18911,6 +19198,7 @@ error: return -1; }
+ /** * virDomainMigrateSetCompressionCache: * @domain: a domain object @@ -18961,6 +19249,7 @@ error: return -1; }
+ /** * virDomainMigrateSetMaxSpeed: * @domain: a domain object @@ -19008,6 +19297,7 @@ error: return -1; }
+ /** * virDomainMigrateGetMaxSpeed: * @domain: a domain object @@ -19057,6 +19347,7 @@ error: return -1; }
+ /** * virConnectDomainEventRegisterAny: * @conn: pointer to the connection @@ -19137,6 +19428,7 @@ error: return -1; }
+ /** * virConnectDomainEventDeregisterAny: * @conn: pointer to the connection @@ -19176,6 +19468,7 @@ error: return -1; }
+ /** * virConnectNetworkEventRegisterAny: * @conn: pointer to the connection @@ -19260,6 +19553,7 @@ error: return -1; }
+ /** * virConnectNetworkEventDeregisterAny: * @conn: pointer to the connection @@ -19301,6 +19595,7 @@ error: return -1; }
+ /** * virDomainManagedSave: * @dom: pointer to the domain @@ -19330,7 +19625,8 @@ error: * * Returns 0 in case of success or -1 in case of failure */ -int virDomainManagedSave(virDomainPtr dom, unsigned int flags) +int +virDomainManagedSave(virDomainPtr dom, unsigned int flags) { virConnectPtr conn;
@@ -19373,6 +19669,7 @@ error: return -1; }
+ /** * virDomainHasManagedSaveImage: * @dom: pointer to the domain @@ -19385,7 +19682,8 @@ error: * Returns 0 if no image is present, 1 if an image is present, and * -1 in case of error */ -int virDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) +int +virDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) { virConnectPtr conn;
@@ -19417,6 +19715,7 @@ error: return -1; }
+ /** * virDomainManagedSaveRemove: * @dom: pointer to the domain @@ -19426,7 +19725,8 @@ error: * * Returns 0 in case of success, and -1 in case of error */ -int virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) +int +virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) { virConnectPtr conn;
@@ -19462,6 +19762,7 @@ error: return -1; }
+ /** * virDomainSnapshotGetName: * @snapshot: a snapshot object @@ -19487,6 +19788,7 @@ virDomainSnapshotGetName(virDomainSnapshotPtr snapshot) return snapshot->name; }
+ /** * virDomainSnapshotGetDomain: * @snapshot: a snapshot object @@ -19516,6 +19818,7 @@ virDomainSnapshotGetDomain(virDomainSnapshotPtr snapshot) return snapshot->domain; }
+ /** * virDomainSnapshotGetConnect: * @snapshot: a snapshot object @@ -19545,6 +19848,7 @@ virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot) return snapshot->domain->conn; }
+ /** * virDomainSnapshotCreateXML: * @domain: a domain object @@ -19704,6 +20008,7 @@ error: return NULL; }
+ /** * virDomainSnapshotGetXMLDesc: * @snapshot: a domain snapshot object @@ -19757,6 +20062,7 @@ error: return NULL; }
+ /** * virDomainSnapshotNum: * @domain: a domain object @@ -19827,6 +20133,7 @@ error: return -1; }
+ /** * virDomainSnapshotListNames: * @domain: a domain object @@ -19918,6 +20225,7 @@ error: return -1; }
+ /** * virDomainListAllSnapshots: * @domain: a domain object @@ -20003,6 +20311,7 @@ error: return -1; }
+ /** * virDomainSnapshotNumChildren: * @snapshot: a domain snapshot object @@ -20074,6 +20383,7 @@ error: return -1; }
+ /** * virDomainSnapshotListChildrenNames: * @snapshot: a domain snapshot object @@ -20171,6 +20481,7 @@ error: return -1; }
+ /** * virDomainSnapshotListAllChildren: * @snapshot: a domain snapshot object @@ -20259,6 +20570,7 @@ error: return -1; }
+ /** * virDomainSnapshotLookupByName: * @domain: a domain object @@ -20306,6 +20618,7 @@ error: return NULL; }
+ /** * virDomainHasCurrentSnapshot: * @domain: pointer to the domain object @@ -20345,6 +20658,7 @@ error: return -1; }
+ /** * virDomainSnapshotCurrent: * @domain: a domain object @@ -20388,6 +20702,7 @@ error: return NULL; }
+ /** * virDomainSnapshotGetParent: * @snapshot: a snapshot object @@ -20432,6 +20747,7 @@ error: return NULL; }
+ /** * virDomainSnapshotIsCurrent: * @snapshot: a snapshot object @@ -20442,8 +20758,9 @@ error: * * Returns 1 if current, 0 if not current, or -1 on error. */ -int virDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, - unsigned int flags) +int +virDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, + unsigned int flags) { virConnectPtr conn;
@@ -20474,6 +20791,7 @@ error: return -1; }
+ /** * virDomainSnapshotHasMetadata: * @snapshot: a snapshot object @@ -20485,8 +20803,9 @@ error: * Returns 1 if the snapshot has metadata, 0 if the snapshot exists without * help from libvirt, or -1 on error. */ -int virDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, - unsigned int flags) +int +virDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, + unsigned int flags) { virConnectPtr conn;
@@ -20517,6 +20836,7 @@ error: return -1; }
+ /** * virDomainRevertToSnapshot: * @snapshot: a domain snapshot object @@ -20604,6 +20924,7 @@ error: return -1; }
+ /** * virDomainSnapshotDelete: * @snapshot: a domain snapshot object @@ -20673,6 +20994,7 @@ error: return -1; }
+ /** * virDomainSnapshotRef: * @snapshot: the snapshot to hold a reference on @@ -20704,6 +21026,7 @@ virDomainSnapshotRef(virDomainSnapshotPtr snapshot) return 0; }
+ /** * virDomainSnapshotFree: * @snapshot: a domain snapshot object @@ -20730,6 +21053,7 @@ virDomainSnapshotFree(virDomainSnapshotPtr snapshot) return 0; }
+ /** * virDomainOpenConsole: * @dom: a domain object @@ -20760,10 +21084,11 @@ virDomainSnapshotFree(virDomainSnapshotPtr snapshot) * * Returns 0 if the console was opened, -1 on error */ -int virDomainOpenConsole(virDomainPtr dom, - const char *dev_name, - virStreamPtr st, - unsigned int flags) +int +virDomainOpenConsole(virDomainPtr dom, + const char *dev_name, + virStreamPtr st, + unsigned int flags) { virConnectPtr conn;
@@ -20799,6 +21124,7 @@ error: return -1; }
+ /** * virDomainOpenChannel: * @dom: a domain object @@ -20821,10 +21147,11 @@ error: * * Returns 0 if the channel was opened, -1 on error */ -int virDomainOpenChannel(virDomainPtr dom, - const char *name, - virStreamPtr st, - unsigned int flags) +int +virDomainOpenChannel(virDomainPtr dom, + const char *name, + virStreamPtr st, + unsigned int flags) { virConnectPtr conn;
@@ -20860,6 +21187,7 @@ error: return -1; }
+ /** * virDomainBlockJobAbort: * @dom: pointer to domain object @@ -20900,8 +21228,9 @@ error: * * Returns -1 in case of failure, 0 when successful. */ -int virDomainBlockJobAbort(virDomainPtr dom, const char *disk, - unsigned int flags) +int +virDomainBlockJobAbort(virDomainPtr dom, const char *disk, + unsigned int flags) { virConnectPtr conn;
@@ -20938,6 +21267,7 @@ error: return -1; }
+ /** * virDomainGetBlockJobInfo: * @dom: pointer to domain object @@ -20957,8 +21287,9 @@ error: * * Returns -1 in case of failure, 0 when nothing found, 1 when info was found. */ -int virDomainGetBlockJobInfo(virDomainPtr dom, const char *disk, - virDomainBlockJobInfoPtr info, unsigned int flags) +int +virDomainGetBlockJobInfo(virDomainPtr dom, const char *disk, + virDomainBlockJobInfoPtr info, unsigned int flags) { virConnectPtr conn;
@@ -20993,6 +21324,7 @@ error: return -1; }
+ /** * virDomainBlockJobSetSpeed: * @dom: pointer to domain object @@ -21012,8 +21344,9 @@ error: * * Returns -1 in case of failure, 0 when successful. */ -int virDomainBlockJobSetSpeed(virDomainPtr dom, const char *disk, - unsigned long bandwidth, unsigned int flags) +int +virDomainBlockJobSetSpeed(virDomainPtr dom, const char *disk, + unsigned long bandwidth, unsigned int flags) { virConnectPtr conn;
@@ -21051,6 +21384,7 @@ error: return -1; }
+ /** * virDomainBlockPull: * @dom: pointer to domain object @@ -21084,8 +21418,9 @@ error: * * Returns 0 if the operation has started, -1 on failure. */ -int virDomainBlockPull(virDomainPtr dom, const char *disk, - unsigned long bandwidth, unsigned int flags) +int +virDomainBlockPull(virDomainPtr dom, const char *disk, + unsigned long bandwidth, unsigned int flags) { virConnectPtr conn;
@@ -21202,9 +21537,10 @@ error: * * Returns 0 if the operation has started, -1 on failure. */ -int virDomainBlockRebase(virDomainPtr dom, const char *disk, - const char *base, unsigned long bandwidth, - unsigned int flags) +int +virDomainBlockRebase(virDomainPtr dom, const char *disk, + const char *base, unsigned long bandwidth, + unsigned int flags) { virConnectPtr conn;
@@ -21320,9 +21656,10 @@ error: * * Returns 0 if the operation has started, -1 on failure. */ -int virDomainBlockCommit(virDomainPtr dom, const char *disk, - const char *base, const char *top, - unsigned long bandwidth, unsigned int flags) +int +virDomainBlockCommit(virDomainPtr dom, const char *disk, + const char *base, const char *top, + unsigned long bandwidth, unsigned int flags) { virConnectPtr conn;
@@ -21386,10 +21723,11 @@ error: * * Returns 0 on success, -1 on failure */ -int virDomainOpenGraphics(virDomainPtr dom, - unsigned int idx, - int fd, - unsigned int flags) +int +virDomainOpenGraphics(virDomainPtr dom, + unsigned int idx, + int fd, + unsigned int flags) { struct stat sb; VIR_DOMAIN_DEBUG(dom, "idx=%u, fd=%d, flags=%x", @@ -21470,9 +21808,10 @@ error: * Returns -1 on error, 0 on success, 1 when remote party doesn't support * keepalive messages. */ -int virConnectSetKeepAlive(virConnectPtr conn, - int interval, - unsigned int count) +int +virConnectSetKeepAlive(virConnectPtr conn, + int interval, + unsigned int count) { int ret = -1;
@@ -21500,6 +21839,7 @@ error: return -1; }
+ /** * virConnectIsAlive: * @conn: pointer to the connection object @@ -21511,7 +21851,8 @@ error: * * Returns 1 if alive, 0 if dead, -1 on error */ -int virConnectIsAlive(virConnectPtr conn) +int +virConnectIsAlive(virConnectPtr conn) { VIR_DEBUG("conn=%p", conn);
@@ -21560,10 +21901,11 @@ error: * * Returns 0 on success, -1 on error */ -int virConnectRegisterCloseCallback(virConnectPtr conn, - virConnectCloseFunc cb, - void *opaque, - virFreeCallback freecb) +int +virConnectRegisterCloseCallback(virConnectPtr conn, + virConnectCloseFunc cb, + void *opaque, + virFreeCallback freecb) { VIR_DEBUG("conn=%p", conn);
@@ -21606,6 +21948,7 @@ error: return -1; }
+ /** * virConnectUnregisterCloseCallback: * @conn: pointer to connection object @@ -21619,8 +21962,9 @@ error: * * Returns 0 on success, -1 on error */ -int virConnectUnregisterCloseCallback(virConnectPtr conn, - virConnectCloseFunc cb) +int +virConnectUnregisterCloseCallback(virConnectPtr conn, + virConnectCloseFunc cb) { VIR_DEBUG("conn=%p", conn);
@@ -21661,6 +22005,7 @@ error: return -1; }
+ /** * virDomainSetBlockIoTune: * @dom: pointer to domain object @@ -21681,11 +22026,12 @@ error: * * Returns -1 in case of error, 0 in case of success. */ -int virDomainSetBlockIoTune(virDomainPtr dom, - const char *disk, - virTypedParameterPtr params, - int nparams, - unsigned int flags) +int +virDomainSetBlockIoTune(virDomainPtr dom, + const char *disk, + virTypedParameterPtr params, + int nparams, + unsigned int flags) { virConnectPtr conn;
@@ -21730,6 +22076,7 @@ error: return -1; }
+ /** * virDomainGetBlockIoTune: * @dom: pointer to domain object @@ -21763,11 +22110,12 @@ error: * * Returns -1 in case of error, 0 in case of success. */ -int virDomainGetBlockIoTune(virDomainPtr dom, - const char *disk, - virTypedParameterPtr params, - int *nparams, - unsigned int flags) +int +virDomainGetBlockIoTune(virDomainPtr dom, + const char *disk, + virTypedParameterPtr params, + int *nparams, + unsigned int flags) { virConnectPtr conn;
@@ -21818,6 +22166,7 @@ error: return -1; }
+ /** * virDomainGetCPUStats: * @domain: domain to query @@ -21892,12 +22241,13 @@ error: * @ncpus is too large). The caller is responsible for freeing any * returned string parameters. */ -int virDomainGetCPUStats(virDomainPtr domain, - virTypedParameterPtr params, - unsigned int nparams, - int start_cpu, - unsigned int ncpus, - unsigned int flags) +int +virDomainGetCPUStats(virDomainPtr domain, + virTypedParameterPtr params, + unsigned int nparams, + int start_cpu, + unsigned int ncpus, + unsigned int flags) { virConnectPtr conn;
@@ -21963,6 +22313,7 @@ error: return -1; }
+ /** * virDomainGetDiskErrors: * @dom: a domain object @@ -22028,6 +22379,7 @@ error: return -1; }
+ /** * virDomainGetHostname: * @domain: a domain object @@ -22073,6 +22425,7 @@ error: return NULL; }
+ /** * virNodeGetCPUMap: * @conn: pointer to the hypervisor connection @@ -22124,6 +22477,7 @@ error: return -1; }
+ /** * virDomainFSTrim: * @dom: a domain object

On 01/02/2014 08:29 AM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
Preliminary cleanups to make search-and-replace easier in later patches.
* src/libvirt.c: Uniform two spaces between functions, return type and open brace on separate line, and label in column 1.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 718 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 536 insertions(+), 182 deletions(-)
Well -someone- was busy during the holidays :-)
I was _trying_ to implement qemu monitor events as a pet project on my own time, but kept running into pre-existing issue after issue with existing event and documentation stuff (and this entire libvirt.c cleanup series was prompted by the fact that I copied-and-pasted from libvirt.c to libvirt-qemu.c, but compilation failed because of inconsistencies between the two). :)
Figured this was as good as place as any to start... I did peek at the "final product", but since this first patch was about consistency of function decls, parameters, etc. I figured I'd do a summary here rather than trying to find each in the lines below.
In general it's very mechanical, but there were a few misses:
Thanks for spotting those; I'll incorporate fixes.
1. The following didn't follow the rules exactly:
$ grep "^char \*" libvirt.c | grep -v "^char \*$" char *virConnectDomainXMLFromNative(virConnectPtr conn,
I did the same for 'unsigned char *', 'int', 'unsigned int', 'unsigned long', and various 'vir*Ptr' return types (Domain, Connect, Network, Interface, StoragePool, StorageVol, NodeDevice, Secret, Stream, NWFilter, and DomainSnapshot). I think I covered all the various return types I saw, but I supposed I could have missed a few...
I think you found them all - the only time we return pointers is either via typedef ending in Ptr (which my greps covered) or via variants of 'char *' (which you found) - all other pointers are passed as parameters rather than return type.
4. And the copyright will I know be fixed the next time you touch the file...
yep, that already happened in commit c8f95ff :)
ACK with the changes
Here's what I squashed in, before pushing: diff --git i/src/libvirt.c w/src/libvirt.c index eba3448..69ee4ac 100644 --- i/src/libvirt.c +++ w/src/libvirt.c @@ -3009,7 +3009,7 @@ error: */ int virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml, - unsigned int flags) + unsigned int flags) { VIR_DEBUG("conn=%p, from=%s, dxml=%s, flags=%x", conn, from, NULLSTR(dxml), flags); @@ -4382,8 +4382,8 @@ error: */ int virDomainSetBlkioParameters(virDomainPtr domain, - virTypedParameterPtr params, - int nparams, unsigned int flags) + virTypedParameterPtr params, + int nparams, unsigned int flags) { virConnectPtr conn; @@ -4454,8 +4454,8 @@ error: */ int virDomainGetBlkioParameters(virDomainPtr domain, - virTypedParameterPtr params, - int *nparams, unsigned int flags) + virTypedParameterPtr params, + int *nparams, unsigned int flags) { virConnectPtr conn; @@ -4720,10 +4720,11 @@ error: * Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. * the caller must free() the returned value. */ -char *virConnectDomainXMLFromNative(virConnectPtr conn, - const char *nativeFormat, - const char *nativeConfig, - unsigned int flags) +char * +virConnectDomainXMLFromNative(virConnectPtr conn, + const char *nativeFormat, + const char *nativeConfig, + unsigned int flags) { VIR_DEBUG("conn=%p, format=%s, config=%s, flags=%x", conn, nativeFormat, nativeConfig, flags); @@ -4776,10 +4777,11 @@ error: * Returns a 0 terminated UTF-8 encoded native config datafile, or NULL in case of error. * the caller must free() the returned value. */ -char *virConnectDomainXMLToNative(virConnectPtr conn, - const char *nativeFormat, - const char *domainXml, - unsigned int flags) +char * +virConnectDomainXMLToNative(virConnectPtr conn, + const char *nativeFormat, + const char *domainXml, + unsigned int flags) { VIR_DEBUG("conn=%p, format=%s, xml=%s, flags=%x", conn, nativeFormat, domainXml, flags); @@ -7104,7 +7106,6 @@ virDomainMigratePrepareTunnel3(virConnectPtr conn, const char *dname, unsigned long bandwidth, const char *dom_xml) - { VIR_DEBUG("conn=%p, stream=%p, cookiein=%p, cookieinlen=%d, cookieout=%p, " "cookieoutlen=%p, flags=%lx, dname=%s, bandwidth=%lu, " @@ -7433,7 +7434,6 @@ virDomainMigratePrepareTunnel3Params(virConnectPtr conn, char **cookieout, int *cookieoutlen, unsigned int flags) - { VIR_DEBUG("conn=%p, stream=%p, params=%p, nparams=%d, cookiein=%p, " "cookieinlen=%d, cookieout=%p, cookieoutlen=%p, flags=%x", @@ -7969,7 +7969,6 @@ virNodeSuspendForDuration(virConnectPtr conn, unsigned long long duration, unsigned int flags) { - VIR_DEBUG("conn=%p, target=%d, duration=%lld, flags=%x", conn, target, duration, flags); @@ -15803,7 +15802,8 @@ error: * * Returns the XML document, or NULL on error */ -char *virNodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags) +char * +virNodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags) { VIR_DEBUG("dev=%p, conn=%p, flags=%x", dev, dev ? dev->conn : NULL, flags); @@ -15839,7 +15839,8 @@ error: * * Returns the device name or NULL in case of error */ -const char *virNodeDeviceGetName(virNodeDevicePtr dev) +const char * +virNodeDeviceGetName(virNodeDevicePtr dev) { VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL); @@ -15862,7 +15863,8 @@ const char *virNodeDeviceGetName(virNodeDevicePtr dev) * Returns the name of the device's parent, or NULL if the * device has no parent. */ -const char *virNodeDeviceGetParent(virNodeDevicePtr dev) +const char * +virNodeDeviceGetParent(virNodeDevicePtr dev) { VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL); -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

I noticed that the virDomainQemuMonitorCommand debug output wasn't telling me the name of the domain it was working on. While it was easy enough to determine which pointer matches the domain based on other log messages, it is nicer to be consistent. * src/util/viruuid.h (VIR_UUID_DEBUG): Moved here from... * src/libvirt.c (VIR_UUID_DEBUG): ...here. (VIR_ARG15, VIR_HAS_COMMA, VIR_DOMAIN_DEBUG_EXPAND) (VIR_DOMAIN_DEBUG_PASTE, VIR_DOMAIN_DEBUG_0, VIR_DOMAIN_DEBUG_1) (VIR_DOMAIN_DEBUG_2, VIR_DOMAIN_DEBUG): Move... * src/datatypes.h: ...here. * src/libvirt-qemu.c (virDomainQemuMonitorCommand) (virDomainQemuAgentCommand): Better debug messages. * src/libvirt-lxc.c (virDomainLxcOpenNamespace): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 60 ++++++++++++++++++++++++++++++++++++++++++++- src/libvirt-lxc.c | 4 +-- src/libvirt-qemu.c | 11 +++++---- src/libvirt.c | 71 ------------------------------------------------------ src/util/viruuid.h | 20 ++++++++++++++- 5 files changed, 86 insertions(+), 80 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index 6026bb0..7f325b0 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -1,7 +1,7 @@ /* * datatypes.h: management of structs for public data types * - * Copyright (C) 2006-2008, 2010-2011 Red Hat, Inc. + * Copyright (C) 2006-2008, 2010-2011, 2013 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -94,6 +94,64 @@ extern virClassPtr virStoragePoolClass; (VIR_IS_SNAPSHOT(obj) && VIR_IS_DOMAIN((obj)->domain)) +/* Helper macros to implement VIR_DOMAIN_DEBUG using just C99. This + * assumes you pass fewer than 15 arguments to VIR_DOMAIN_DEBUG, but + * can easily be expanded if needed. + * + * Note that gcc provides extensions of "define a(b...) b" or + * "define a(b,...) b,##__VA_ARGS__" as a means of eliding a comma + * when no var-args are present, but we don't want to require gcc. + */ +# define VIR_ARG15(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \ + _11, _12, _13, _14, _15, ...) _15 +# define VIR_HAS_COMMA(...) VIR_ARG15(__VA_ARGS__, \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0) + +/* Form the name VIR_DOMAIN_DEBUG_[01], then call that macro, + * according to how many arguments are present. Two-phase due to + * macro expansion rules. */ +# define VIR_DOMAIN_DEBUG_EXPAND(a, b, ...) \ + VIR_DOMAIN_DEBUG_PASTE(a, b, __VA_ARGS__) +# define VIR_DOMAIN_DEBUG_PASTE(a, b, ...) \ + a##b(__VA_ARGS__) + +/* Internal use only, when VIR_DOMAIN_DEBUG has one argument. */ +# define VIR_DOMAIN_DEBUG_0(dom) \ + VIR_DOMAIN_DEBUG_2(dom, "%s", "") + +/* Internal use only, when VIR_DOMAIN_DEBUG has three or more arguments. */ +# define VIR_DOMAIN_DEBUG_1(dom, fmt, ...) \ + VIR_DOMAIN_DEBUG_2(dom, ", " fmt, __VA_ARGS__) + +/* Internal use only, with final format. */ +# define VIR_DOMAIN_DEBUG_2(dom, fmt, ...) \ + do { \ + char _uuidstr[VIR_UUID_STRING_BUFLEN]; \ + const char *_domname = NULL; \ + \ + if (!VIR_IS_DOMAIN(dom)) { \ + memset(_uuidstr, 0, sizeof(_uuidstr)); \ + } else { \ + virUUIDFormat((dom)->uuid, _uuidstr); \ + _domname = (dom)->name; \ + } \ + \ + VIR_DEBUG("dom=%p, (VM: name=%s, uuid=%s)" fmt, \ + dom, NULLSTR(_domname), _uuidstr, __VA_ARGS__); \ + } while (0) + +/** + * VIR_DOMAIN_DEBUG: + * @dom: domain + * @fmt: optional format for additional information + * @...: optional arguments corresponding to @fmt. + */ +# define VIR_DOMAIN_DEBUG(...) \ + VIR_DOMAIN_DEBUG_EXPAND(VIR_DOMAIN_DEBUG_, \ + VIR_HAS_COMMA(__VA_ARGS__), \ + __VA_ARGS__) + + typedef struct _virConnectCloseCallbackData virConnectCloseCallbackData; typedef virConnectCloseCallbackData *virConnectCloseCallbackDataPtr; diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index c8cdcea..5cbe8bf 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -28,6 +28,7 @@ #include "virfile.h" #include "virlog.h" #include "virprocess.h" +#include "viruuid.h" #include "datatypes.h" #ifdef WITH_SELINUX # include <selinux/selinux.h> @@ -69,8 +70,7 @@ virDomainLxcOpenNamespace(virDomainPtr domain, { virConnectPtr conn; - VIR_DEBUG("domain=%p, fdlist=%p flags=%x", - domain, fdlist, flags); + VIR_DOMAIN_DEBUG(domain, "fdlist=%p flags=%x", fdlist, flags); virResetLastError(); diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 83fb3b3..2fa5522 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -2,7 +2,7 @@ * libvirt-qemu.c: Interfaces for the libvirt library to handle qemu-specific * APIs. * - * Copyright (C) 2010-2012 Red Hat, Inc. + * Copyright (C) 2010-2013 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,7 @@ #include "virerror.h" #include "virlog.h" +#include "viruuid.h" #include "datatypes.h" #define VIR_FROM_THIS VIR_FROM_NONE @@ -75,8 +76,8 @@ virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, { virConnectPtr conn; - VIR_DEBUG("domain=%p, cmd=%s, result=%p, flags=%x", - domain, cmd, result, flags); + VIR_DOMAIN_DEBUG(domain, "cmd=%s, result=%p, flags=%x", + cmd, result, flags); virResetLastError(); @@ -213,8 +214,8 @@ virDomainQemuAgentCommand(virDomainPtr domain, virConnectPtr conn; char *ret; - VIR_DEBUG("domain=%p, cmd=%s, timeout=%d, flags=%x", - domain, cmd, timeout, flags); + VIR_DOMAIN_DEBUG(domain, "cmd=%s, timeout=%d, flags=%x", + cmd, timeout, flags); if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); diff --git a/src/libvirt.c b/src/libvirt.c index 8066b7c..f145d74 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -341,77 +341,6 @@ static struct gcry_thread_cbs virTLSThreadImpl = { }; #endif /* WITH_GNUTLS_GCRYPT */ -/* Helper macros to implement VIR_DOMAIN_DEBUG using just C99. This - * assumes you pass fewer than 15 arguments to VIR_DOMAIN_DEBUG, but - * can easily be expanded if needed. - * - * Note that gcc provides extensions of "define a(b...) b" or - * "define a(b,...) b,##__VA_ARGS__" as a means of eliding a comma - * when no var-args are present, but we don't want to require gcc. - */ -#define VIR_ARG15(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, ...) _15 -#define VIR_HAS_COMMA(...) VIR_ARG15(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0) - -/* Form the name VIR_DOMAIN_DEBUG_[01], then call that macro, - * according to how many arguments are present. Two-phase due to - * macro expansion rules. */ -#define VIR_DOMAIN_DEBUG_EXPAND(a, b, ...) \ - VIR_DOMAIN_DEBUG_PASTE(a, b, __VA_ARGS__) -#define VIR_DOMAIN_DEBUG_PASTE(a, b, ...) \ - a##b(__VA_ARGS__) - -/* Internal use only, when VIR_DOMAIN_DEBUG has one argument. */ -#define VIR_DOMAIN_DEBUG_0(dom) \ - VIR_DOMAIN_DEBUG_2(dom, "%s", "") - -/* Internal use only, when VIR_DOMAIN_DEBUG has three or more arguments. */ -#define VIR_DOMAIN_DEBUG_1(dom, fmt, ...) \ - VIR_DOMAIN_DEBUG_2(dom, ", " fmt, __VA_ARGS__) - -/* Internal use only, with final format. */ -#define VIR_DOMAIN_DEBUG_2(dom, fmt, ...) \ - do { \ - char _uuidstr[VIR_UUID_STRING_BUFLEN]; \ - const char *_domname = NULL; \ - \ - if (!VIR_IS_DOMAIN(dom)) { \ - memset(_uuidstr, 0, sizeof(_uuidstr)); \ - } else { \ - virUUIDFormat((dom)->uuid, _uuidstr); \ - _domname = (dom)->name; \ - } \ - \ - VIR_DEBUG("dom=%p, (VM: name=%s, uuid=%s)" fmt, \ - dom, NULLSTR(_domname), _uuidstr, __VA_ARGS__); \ - } while (0) - -/** - * VIR_DOMAIN_DEBUG: - * @dom: domain - * @fmt: optional format for additional information - * @...: optional arguments corresponding to @fmt. - */ -#define VIR_DOMAIN_DEBUG(...) \ - VIR_DOMAIN_DEBUG_EXPAND(VIR_DOMAIN_DEBUG_, \ - VIR_HAS_COMMA(__VA_ARGS__), \ - __VA_ARGS__) - -/** - * VIR_UUID_DEBUG: - * @conn: connection - * @uuid: possibly null UUID array - */ -#define VIR_UUID_DEBUG(conn, uuid) \ - do { \ - if (uuid) { \ - char _uuidstr[VIR_UUID_STRING_BUFLEN]; \ - virUUIDFormat(uuid, _uuidstr); \ - VIR_DEBUG("conn=%p, uuid=%s", conn, _uuidstr); \ - } else { \ - VIR_DEBUG("conn=%p, uuid=(null)", conn); \ - } \ - } while (0) - static bool virGlobalError = false; static virOnceControl virGlobalOnce = VIR_ONCE_CONTROL_INITIALIZER; diff --git a/src/util/viruuid.h b/src/util/viruuid.h index bebd338..b3b1d49 100644 --- a/src/util/viruuid.h +++ b/src/util/viruuid.h @@ -1,7 +1,7 @@ /* * viruuid.h: helper APIs for dealing with UUIDs * - * Copyright (C) 2007, 2011, 2012 Red Hat, Inc. + * Copyright (C) 2007, 2011-2013 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,6 +26,24 @@ # include "internal.h" + +/** + * VIR_UUID_DEBUG: + * @conn: connection + * @uuid: possibly null UUID array + */ +# define VIR_UUID_DEBUG(conn, uuid) \ + do { \ + if (uuid) { \ + char _uuidstr[VIR_UUID_STRING_BUFLEN]; \ + virUUIDFormat(uuid, _uuidstr); \ + VIR_DEBUG("conn=%p, uuid=%s", conn, _uuidstr); \ + } else { \ + VIR_DEBUG("conn=%p, uuid=(null)", conn); \ + } \ + } while (0) + + int virSetHostUUIDStr(const char *host_uuid); int virGetHostUUID(unsigned char *host_uuid) ATTRIBUTE_NONNULL(1); -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
I noticed that the virDomainQemuMonitorCommand debug output wasn't telling me the name of the domain it was working on. While it was easy enough to determine which pointer matches the domain based on other log messages, it is nicer to be consistent.
* src/util/viruuid.h (VIR_UUID_DEBUG): Moved here from... * src/libvirt.c (VIR_UUID_DEBUG): ...here. (VIR_ARG15, VIR_HAS_COMMA, VIR_DOMAIN_DEBUG_EXPAND) (VIR_DOMAIN_DEBUG_PASTE, VIR_DOMAIN_DEBUG_0, VIR_DOMAIN_DEBUG_1) (VIR_DOMAIN_DEBUG_2, VIR_DOMAIN_DEBUG): Move... * src/datatypes.h: ...here. * src/libvirt-qemu.c (virDomainQemuMonitorCommand) (virDomainQemuAgentCommand): Better debug messages. * src/libvirt-lxc.c (virDomainLxcOpenNamespace): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 60 ++++++++++++++++++++++++++++++++++++++++++++- src/libvirt-lxc.c | 4 +-- src/libvirt-qemu.c | 11 +++++---- src/libvirt.c | 71 ------------------------------------------------------ src/util/viruuid.h | 20 ++++++++++++++- 5 files changed, 86 insertions(+), 80 deletions(-)
Seems to follow what Daniel suggested. ACK John

On 01/02/2014 09:00 AM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
I noticed that the virDomainQemuMonitorCommand debug output wasn't telling me the name of the domain it was working on. While it was easy enough to determine which pointer matches the domain based on other log messages, it is nicer to be consistent.
* src/util/viruuid.h (VIR_UUID_DEBUG): Moved here from... * src/libvirt.c (VIR_UUID_DEBUG): ...here. (VIR_ARG15, VIR_HAS_COMMA, VIR_DOMAIN_DEBUG_EXPAND) (VIR_DOMAIN_DEBUG_PASTE, VIR_DOMAIN_DEBUG_0, VIR_DOMAIN_DEBUG_1) (VIR_DOMAIN_DEBUG_2, VIR_DOMAIN_DEBUG): Move... * src/datatypes.h: ...here. * src/libvirt-qemu.c (virDomainQemuMonitorCommand) (virDomainQemuAgentCommand): Better debug messages. * src/libvirt-lxc.c (virDomainLxcOpenNamespace): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 60 ++++++++++++++++++++++++++++++++++++++++++++- src/libvirt-lxc.c | 4 +-- src/libvirt-qemu.c | 11 +++++---- src/libvirt.c | 71 ------------------------------------------------------ src/util/viruuid.h | 20 ++++++++++++++- 5 files changed, 86 insertions(+), 80 deletions(-)
Seems to follow what Daniel suggested.
ACK
Pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Most of our public APIs emit a debug log on entry, prior to anything else. There were a few exceptions where obvious failures were not logged, so fix those. Many of the fixes are made more careful to avoid a NULL deref if the user passes NULL for the object. * src/libvirt.c (virConnectOpen, virConnectOpenReadOnly) (virConnectOpenAuth, virConnectRef, virDomainRef) (virNetworkRef, virInterfaceRef, virStoragePoolRef) (virStorageVolRef, virNodeDeviceRef, virSecretRef, virStreamRef) (virNWFilterRef, virDomainSnapshotRef): Debug on function entry. * src/libvirt-lxc.c (virDomainLxcEnterNamespace) (virDomainLxcEnterSecurityLabel): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt-lxc.c | 7 +++++++ src/libvirt.c | 53 +++++++++++++++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index 5cbe8bf..7ffed3e 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -138,6 +138,10 @@ virDomainLxcEnterNamespace(virDomainPtr domain, { size_t i; + VIR_DOMAIN_DEBUG(domain, "nfdlist=%d, fdlist=%p, " + "noldfdlist=%p, oldfdlist=%p, flags=%x", + nfdlist, fdlist, noldfdlist, oldfdlist, flags); + virCheckFlagsGoto(0, error); if (noldfdlist && oldfdlist) { @@ -196,6 +200,9 @@ virDomainLxcEnterSecurityLabel(virSecurityModelPtr model, virSecurityLabelPtr oldlabel, unsigned int flags) { + VIR_DEBUG("model=%p, label=%p, oldlabel=%p, flags=%x", + model, label, oldlabel, flags); + virCheckFlagsGoto(0, error); virCheckNonNullArgGoto(model, error); diff --git a/src/libvirt.c b/src/libvirt.c index f145d74..815dd64 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1367,10 +1367,11 @@ virConnectOpen(const char *name) { virConnectPtr ret = NULL; + VIR_DEBUG("name=%s", NULLSTR(name)); + if (virInitialize() < 0) goto error; - VIR_DEBUG("name=%s", NULLSTR(name)); virResetLastError(); ret = do_open(name, NULL, 0); if (!ret) @@ -1403,10 +1404,11 @@ virConnectOpenReadOnly(const char *name) { virConnectPtr ret = NULL; + VIR_DEBUG("name=%s", NULLSTR(name)); + if (virInitialize() < 0) goto error; - VIR_DEBUG("name=%s", NULLSTR(name)); virResetLastError(); ret = do_open(name, NULL, VIR_CONNECT_RO); if (!ret) @@ -1443,10 +1445,11 @@ virConnectOpenAuth(const char *name, { virConnectPtr ret = NULL; + VIR_DEBUG("name=%s, auth=%p, flags=%x", NULLSTR(name), auth, flags); + if (virInitialize() < 0) goto error; - VIR_DEBUG("name=%s, auth=%p, flags=%x", NULLSTR(name), auth, flags); virResetLastError(); ret = do_open(name, auth, flags); if (!ret) @@ -1530,12 +1533,13 @@ error: int virConnectRef(virConnectPtr conn) { + VIR_DEBUG("conn=%p refs=%d", conn, conn ? conn->object.u.s.refs : 0); + if ((!VIR_IS_CONNECT(conn))) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("conn=%p refs=%d", conn, conn->object.u.s.refs); virObjectRef(conn); return 0; } @@ -2457,13 +2461,14 @@ virDomainFree(virDomainPtr domain) int virDomainRef(virDomainPtr domain) { + VIR_DOMAIN_DEBUG(domain, "refs=%d", domain ? domain->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_DOMAIN(domain))) { virLibConnError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DOMAIN_DEBUG(domain, "refs=%d", domain->object.u.s.refs); virObjectRef(domain); return 0; } @@ -7033,7 +7038,6 @@ virDomainMigratePrepareTunnel3(virConnectPtr conn, const char *dname, unsigned long bandwidth, const char *dom_xml) - { VIR_DEBUG("conn=%p, stream=%p, cookiein=%p, cookieinlen=%d, cookieout=%p, " "cookieoutlen=%p, flags=%lx, dname=%s, bandwidth=%lu, " @@ -7362,7 +7366,6 @@ virDomainMigratePrepareTunnel3Params(virConnectPtr conn, char **cookieout, int *cookieoutlen, unsigned int flags) - { VIR_DEBUG("conn=%p, stream=%p, params=%p, nparams=%d, cookiein=%p, " "cookieinlen=%d, cookieout=%p, cookieoutlen=%p, flags=%x", @@ -7898,7 +7901,6 @@ virNodeSuspendForDuration(virConnectPtr conn, unsigned long long duration, unsigned int flags) { - VIR_DEBUG("conn=%p, target=%d, duration=%lld, flags=%x", conn, target, duration, flags); @@ -12078,12 +12080,14 @@ virNetworkFree(virNetworkPtr network) int virNetworkRef(virNetworkPtr network) { + VIR_DEBUG("network=%p refs=%d", network, + network ? network->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_NETWORK(network))) { virLibConnError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("network=%p refs=%d", network, network->object.u.s.refs); virObjectRef(network); return 0; } @@ -13046,12 +13050,13 @@ error: int virInterfaceRef(virInterfacePtr iface) { + VIR_DEBUG("iface=%p refs=%d", iface, iface ? iface->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_INTERFACE(iface))) { virLibConnError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("iface=%p refs=%d", iface, iface->object.u.s.refs); virObjectRef(iface); return 0; } @@ -14116,12 +14121,13 @@ virStoragePoolFree(virStoragePoolPtr pool) int virStoragePoolRef(virStoragePoolPtr pool) { + VIR_DEBUG("pool=%p refs=%d", pool, pool ? pool->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_STORAGE_POOL(pool))) { virLibConnError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("pool=%p refs=%d", pool, pool->object.u.s.refs); virObjectRef(pool); return 0; } @@ -15242,12 +15248,13 @@ virStorageVolFree(virStorageVolPtr vol) int virStorageVolRef(virStorageVolPtr vol) { + VIR_DEBUG("vol=%p refs=%d", vol, vol ? vol->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_STORAGE_VOL(vol))) { virLibConnError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("vol=%p refs=%d", vol, vol->object.u.s.refs); virObjectRef(vol); return 0; } @@ -15947,12 +15954,13 @@ virNodeDeviceFree(virNodeDevicePtr dev) int virNodeDeviceRef(virNodeDevicePtr dev) { + VIR_DEBUG("dev=%p refs=%d", dev, dev ? dev->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_NODE_DEVICE(dev))) { virLibConnError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("dev=%p refs=%d", dev, dev->object.u.s.refs); virObjectRef(dev); return 0; } @@ -17074,12 +17082,14 @@ error: int virSecretRef(virSecretPtr secret) { + VIR_DEBUG("secret=%p refs=%d", secret, + secret ? secret->object.u.s.refs : 0); + if (!VIR_IS_CONNECTED_SECRET(secret)) { virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("secret=%p refs=%d", secret, secret->object.u.s.refs); virObjectRef(secret); return 0; } @@ -17169,12 +17179,14 @@ virStreamNew(virConnectPtr conn, int virStreamRef(virStreamPtr stream) { + VIR_DEBUG("stream=%p refs=%d", stream, + stream ? stream->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_STREAM(stream))) { virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("stream=%p refs=%d", stream, stream->object.u.s.refs); virObjectRef(stream); return 0; } @@ -17597,7 +17609,8 @@ virStreamEventAddCallback(virStreamPtr stream, void *opaque, virFreeCallback ff) { - VIR_DEBUG("stream=%p, events=%d, cb=%p, opaque=%p, ff=%p", stream, events, cb, opaque, ff); + VIR_DEBUG("stream=%p, events=%d, cb=%p, opaque=%p, ff=%p", + stream, events, cb, opaque, ff); virResetLastError(); @@ -18606,12 +18619,14 @@ error: int virNWFilterRef(virNWFilterPtr nwfilter) { + VIR_DEBUG("nwfilter=%p refs=%d", nwfilter, + nwfilter ? nwfilter->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_NWFILTER(nwfilter))) { virLibConnError(VIR_ERR_INVALID_NWFILTER, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("nwfilter=%p refs=%d", nwfilter, nwfilter->object.u.s.refs); virObjectRef(nwfilter); return 0; } @@ -20944,13 +20959,15 @@ error: int virDomainSnapshotRef(virDomainSnapshotPtr snapshot) { + VIR_DEBUG("snapshot=%p, refs=%d", snapshot, + snapshot ? snapshot->object.u.s.refs : 0); + if ((!VIR_IS_DOMAIN_SNAPSHOT(snapshot))) { virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("snapshot=%p, refs=%d", snapshot, snapshot->object.u.s.refs); virObjectRef(snapshot); return 0; } -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
Most of our public APIs emit a debug log on entry, prior to anything else. There were a few exceptions where obvious failures were not logged, so fix those. Many of the fixes are made more careful to
s/careful/carefully/
avoid a NULL deref if the user passes NULL for the object.
* src/libvirt.c (virConnectOpen, virConnectOpenReadOnly) (virConnectOpenAuth, virConnectRef, virDomainRef) (virNetworkRef, virInterfaceRef, virStoragePoolRef) (virStorageVolRef, virNodeDeviceRef, virSecretRef, virStreamRef) (virNWFilterRef, virDomainSnapshotRef): Debug on function entry. * src/libvirt-lxc.c (virDomainLxcEnterNamespace) (virDomainLxcEnterSecurityLabel): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt-lxc.c | 7 +++++++ src/libvirt.c | 53 +++++++++++++++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 18 deletions(-)
diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index 5cbe8bf..7ffed3e 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -138,6 +138,10 @@ virDomainLxcEnterNamespace(virDomainPtr domain, { size_t i;
+ VIR_DOMAIN_DEBUG(domain, "nfdlist=%d, fdlist=%p, " + "noldfdlist=%p, oldfdlist=%p, flags=%x", + nfdlist, fdlist, noldfdlist, oldfdlist, flags); + virCheckFlagsGoto(0, error);
if (noldfdlist && oldfdlist) { @@ -196,6 +200,9 @@ virDomainLxcEnterSecurityLabel(virSecurityModelPtr model, virSecurityLabelPtr oldlabel, unsigned int flags) { + VIR_DEBUG("model=%p, label=%p, oldlabel=%p, flags=%x", + model, label, oldlabel, flags); + virCheckFlagsGoto(0, error);
virCheckNonNullArgGoto(model, error); diff --git a/src/libvirt.c b/src/libvirt.c index f145d74..815dd64 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1367,10 +1367,11 @@ virConnectOpen(const char *name) { virConnectPtr ret = NULL;
+ VIR_DEBUG("name=%s", NULLSTR(name)); + if (virInitialize() < 0) goto error;
- VIR_DEBUG("name=%s", NULLSTR(name));
For this and other virConnect*()'s being moved before virInitialize()... Something tells me there's some "historical reason" for the VIR_DEBUG() after virInitialize(). Something that perhaps some assumption that virLogMessage() or what it calls may assume has been initialized properly... Although I suppose, since virGetVersion() already will VIR_DEBUG before virInitialize(), it's perhaps just an overly paranoid observation based on a previous job where debug/output logs got filled with messages because due to a similar change and some thread was waiting for initialization to complete and expected a failure from an entry routine such as this. Having 100's of entries in the log was "of concern".
virResetLastError(); ret = do_open(name, NULL, 0); if (!ret) @@ -1403,10 +1404,11 @@ virConnectOpenReadOnly(const char *name) { virConnectPtr ret = NULL;
+ VIR_DEBUG("name=%s", NULLSTR(name)); + if (virInitialize() < 0) goto error;
- VIR_DEBUG("name=%s", NULLSTR(name)); virResetLastError(); ret = do_open(name, NULL, VIR_CONNECT_RO); if (!ret) @@ -1443,10 +1445,11 @@ virConnectOpenAuth(const char *name, { virConnectPtr ret = NULL;
+ VIR_DEBUG("name=%s, auth=%p, flags=%x", NULLSTR(name), auth, flags); + if (virInitialize() < 0) goto error;
- VIR_DEBUG("name=%s, auth=%p, flags=%x", NULLSTR(name), auth, flags); virResetLastError(); ret = do_open(name, auth, flags); if (!ret) @@ -1530,12 +1533,13 @@ error: int virConnectRef(virConnectPtr conn) { + VIR_DEBUG("conn=%p refs=%d", conn, conn ? conn->object.u.s.refs : 0); + if ((!VIR_IS_CONNECT(conn))) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("conn=%p refs=%d", conn, conn->object.u.s.refs); virObjectRef(conn); return 0; } @@ -2457,13 +2461,14 @@ virDomainFree(virDomainPtr domain) int virDomainRef(virDomainPtr domain) { + VIR_DOMAIN_DEBUG(domain, "refs=%d", domain ? domain->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_DOMAIN(domain))) { virLibConnError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); return -1; }
- VIR_DOMAIN_DEBUG(domain, "refs=%d", domain->object.u.s.refs); virObjectRef(domain); return 0; } @@ -7033,7 +7038,6 @@ virDomainMigratePrepareTunnel3(virConnectPtr conn, const char *dname, unsigned long bandwidth, const char *dom_xml) -
Seems to be something more relevant to patch 1 (downside of peeking at finished product for me I guess).
{ VIR_DEBUG("conn=%p, stream=%p, cookiein=%p, cookieinlen=%d, cookieout=%p, " "cookieoutlen=%p, flags=%lx, dname=%s, bandwidth=%lu, " @@ -7362,7 +7366,6 @@ virDomainMigratePrepareTunnel3Params(virConnectPtr conn, char **cookieout, int *cookieoutlen, unsigned int flags) -
Same here w/r/t patch1
{ VIR_DEBUG("conn=%p, stream=%p, params=%p, nparams=%d, cookiein=%p, " "cookieinlen=%d, cookieout=%p, cookieoutlen=%p, flags=%x", @@ -7898,7 +7901,6 @@ virNodeSuspendForDuration(virConnectPtr conn, unsigned long long duration, unsigned int flags) { -
Same here w/r/t patch1 The rest is mechanical code movement and the extra checks for printing of "->object.u.s.refs" ACK - as long as you're satisfied that calling VIR_DEBUG before virInitialize is ok John
VIR_DEBUG("conn=%p, target=%d, duration=%lld, flags=%x", conn, target, duration, flags);
@@ -12078,12 +12080,14 @@ virNetworkFree(virNetworkPtr network) int virNetworkRef(virNetworkPtr network) { + VIR_DEBUG("network=%p refs=%d", network, + network ? network->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_NETWORK(network))) { virLibConnError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("network=%p refs=%d", network, network->object.u.s.refs); virObjectRef(network); return 0; } @@ -13046,12 +13050,13 @@ error: int virInterfaceRef(virInterfacePtr iface) { + VIR_DEBUG("iface=%p refs=%d", iface, iface ? iface->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_INTERFACE(iface))) { virLibConnError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("iface=%p refs=%d", iface, iface->object.u.s.refs); virObjectRef(iface); return 0; } @@ -14116,12 +14121,13 @@ virStoragePoolFree(virStoragePoolPtr pool) int virStoragePoolRef(virStoragePoolPtr pool) { + VIR_DEBUG("pool=%p refs=%d", pool, pool ? pool->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_STORAGE_POOL(pool))) { virLibConnError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("pool=%p refs=%d", pool, pool->object.u.s.refs); virObjectRef(pool); return 0; } @@ -15242,12 +15248,13 @@ virStorageVolFree(virStorageVolPtr vol) int virStorageVolRef(virStorageVolPtr vol) { + VIR_DEBUG("vol=%p refs=%d", vol, vol ? vol->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_STORAGE_VOL(vol))) { virLibConnError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("vol=%p refs=%d", vol, vol->object.u.s.refs); virObjectRef(vol); return 0; } @@ -15947,12 +15954,13 @@ virNodeDeviceFree(virNodeDevicePtr dev) int virNodeDeviceRef(virNodeDevicePtr dev) { + VIR_DEBUG("dev=%p refs=%d", dev, dev ? dev->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_NODE_DEVICE(dev))) { virLibConnError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("dev=%p refs=%d", dev, dev->object.u.s.refs); virObjectRef(dev); return 0; } @@ -17074,12 +17082,14 @@ error: int virSecretRef(virSecretPtr secret) { + VIR_DEBUG("secret=%p refs=%d", secret, + secret ? secret->object.u.s.refs : 0); + if (!VIR_IS_CONNECTED_SECRET(secret)) { virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("secret=%p refs=%d", secret, secret->object.u.s.refs); virObjectRef(secret); return 0; } @@ -17169,12 +17179,14 @@ virStreamNew(virConnectPtr conn, int virStreamRef(virStreamPtr stream) { + VIR_DEBUG("stream=%p refs=%d", stream, + stream ? stream->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_STREAM(stream))) { virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("stream=%p refs=%d", stream, stream->object.u.s.refs); virObjectRef(stream); return 0; } @@ -17597,7 +17609,8 @@ virStreamEventAddCallback(virStreamPtr stream, void *opaque, virFreeCallback ff) { - VIR_DEBUG("stream=%p, events=%d, cb=%p, opaque=%p, ff=%p", stream, events, cb, opaque, ff); + VIR_DEBUG("stream=%p, events=%d, cb=%p, opaque=%p, ff=%p", + stream, events, cb, opaque, ff);
virResetLastError();
@@ -18606,12 +18619,14 @@ error: int virNWFilterRef(virNWFilterPtr nwfilter) { + VIR_DEBUG("nwfilter=%p refs=%d", nwfilter, + nwfilter ? nwfilter->object.u.s.refs : 0); + if ((!VIR_IS_CONNECTED_NWFILTER(nwfilter))) { virLibConnError(VIR_ERR_INVALID_NWFILTER, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("nwfilter=%p refs=%d", nwfilter, nwfilter->object.u.s.refs); virObjectRef(nwfilter); return 0; } @@ -20944,13 +20959,15 @@ error: int virDomainSnapshotRef(virDomainSnapshotPtr snapshot) { + VIR_DEBUG("snapshot=%p, refs=%d", snapshot, + snapshot ? snapshot->object.u.s.refs : 0); + if ((!VIR_IS_DOMAIN_SNAPSHOT(snapshot))) { virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, __FUNCTION__); virDispatchError(NULL); return -1; } - VIR_DEBUG("snapshot=%p, refs=%d", snapshot, snapshot->object.u.s.refs); virObjectRef(snapshot); return 0; }

On 01/02/2014 10:32 AM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
Most of our public APIs emit a debug log on entry, prior to anything else. There were a few exceptions where obvious failures were not logged, so fix those. Many of the fixes are made more careful to
s/careful/carefully/
I went with: Many of the changes include adding more caution to avoid a NULL deref if the user passes NULL for the object.
+++ b/src/libvirt.c @@ -1367,10 +1367,11 @@ virConnectOpen(const char *name) { virConnectPtr ret = NULL;
+ VIR_DEBUG("name=%s", NULLSTR(name)); + if (virInitialize() < 0) goto error;
- VIR_DEBUG("name=%s", NULLSTR(name));
For this and other virConnect*()'s being moved before virInitialize()...
Hmm. We document that for most APIs, you MUST call virInitialize() or virConnectOpen*() first (and that virConnectOpen*() is one of the exceptions that calls virInitialize() on your behalf).
Something tells me there's some "historical reason" for the VIR_DEBUG() after virInitialize(). Something that perhaps some assumption that virLogMessage() or what it calls may assume has been initialized properly...
Indeed - VIR_DEBUG has the potential for different behavior before and after virInitialize(); and if you are trying to log behavior of a client, getting the connection open details logged is important.
Although I suppose, since virGetVersion() already will VIR_DEBUG before virInitialize(), it's perhaps just an overly paranoid observation based on a previous job where debug/output logs got filled with messages because due to a similar change and some thread was waiting for initialization to complete and expected a failure from an entry routine such as this. Having 100's of entries in the log was "of concern".
I'm still thinking about whether to change the location in these functions. But I think you're right, and I should drop those hunks.
@@ -7033,7 +7038,6 @@ virDomainMigratePrepareTunnel3(virConnectPtr conn, const char *dname, unsigned long bandwidth, const char *dom_xml) -
Seems to be something more relevant to patch 1 (downside of peeking at finished product for me I guess).
And I moved it there accordingly.
The rest is mechanical code movement and the extra checks for printing of "->object.u.s.refs"
ACK - as long as you're satisfied that calling VIR_DEBUG before virInitialize is ok
I'll respin this one to keep virInitialize() first. The v2 series will be shorter, though, once I push the non-controversial patches from this review (thanks for tackling it, by the way). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Something tells me there's some "historical reason" for the VIR_DEBUG() after virInitialize(). Something that perhaps some assumption that virLogMessage() or what it calls may assume has been initialized properly...
Indeed - VIR_DEBUG has the potential for different behavior before and after virInitialize(); and if you are trying to log behavior of a client, getting the connection open details logged is important.
ACK - as long as you're satisfied that calling VIR_DEBUG before virInitialize is ok
I'll respin this one to keep virInitialize() first. The v2 series will be shorter, though, once I push the non-controversial patches from this review (thanks for tackling it, by the way).
Actually, after sleeping on it, I decided to just squash this in and push: diff --git i/src/libvirt.c w/src/libvirt.c index b197d96..e8ecbf9 100644 --- i/src/libvirt.c +++ w/src/libvirt.c @@ -348,6 +348,11 @@ static virOnceControl virGlobalOnce = VIR_ONCE_CONTROL_INITIALIZER; static void virGlobalInit(void) { + /* It would be nice if we could trace the use of this call, to + * help diagnose in log files if a user calls something other than + * virConnectOpen first. But we can't rely on VIR_DEBUG working + * until after initialization is complete, and since this is + * one-shot, we never get here again. */ if (virThreadInitialize() < 0 || virErrorInitialize() < 0) goto error; @@ -455,13 +460,18 @@ error: * * Initialize the library. * - * This method is invoked automatically by any of the virConnectOpen API - * calls. Since release 1.0.0, there is no need to call this method even - * in a multithreaded application, since initialization is performed in - * a thread safe manner. + * This method is invoked automatically by any of the virConnectOpen() API + * calls, and by virGetVersion(). Since release 1.0.0, there is no need to + * call this method even in a multithreaded application, since + * initialization is performed in a thread safe manner; but applications + * using an older version of the library should manually call this before + * setting up competing threads that attempt virConnectOpen in parallel. * - * The only time it would be necessary to call virInitialize is if the - * application did not invoke virConnectOpen as its first API call. + * The only other time it would be necessary to call virInitialize is if the + * application did not invoke virConnectOpen as its first API call, such + * as when calling virEventRegisterImpl() before setting up connections, + * or when using virSetErrorFunc() to alter error reporting of the first + * connection attempt. * * Returns 0 in case of success, -1 in case of error */ @@ -904,7 +914,9 @@ virStateStop(void) * but due to the design of remote clients this is not reliable). To * get the version of the running hypervisor use the virConnectGetVersion * function instead. To get the libvirt library version used by a - * connection use the virConnectGetLibVersion instead. + * connection use the virConnectGetLibVersion() instead. + * + * This function includes a call to virInitialize() when necessary. * * Returns -1 in case of failure, 0 otherwise, and values for @libVer and * @typeVer have the format major * 1,000,000 + minor * 1,000 + release. @@ -913,10 +925,9 @@ int virGetVersion(unsigned long *libVer, const char *type ATTRIBUTE_UNUSED, unsigned long *typeVer) { - VIR_DEBUG("libVir=%p, type=%s, typeVer=%p", libVer, type, typeVer); - if (virInitialize() < 0) goto error; + VIR_DEBUG("libVir=%p, type=%s, typeVer=%p", libVer, type, typeVer); if (libVer == NULL) goto error; @@ -1367,10 +1378,9 @@ virConnectOpen(const char *name) { virConnectPtr ret = NULL; - VIR_DEBUG("name=%s", NULLSTR(name)); - if (virInitialize() < 0) goto error; + VIR_DEBUG("name=%s", NULLSTR(name)); virResetLastError(); ret = do_open(name, NULL, 0); @@ -1404,10 +1414,9 @@ virConnectOpenReadOnly(const char *name) { virConnectPtr ret = NULL; - VIR_DEBUG("name=%s", NULLSTR(name)); - if (virInitialize() < 0) goto error; + VIR_DEBUG("name=%s", NULLSTR(name)); virResetLastError(); ret = do_open(name, NULL, VIR_CONNECT_RO); @@ -1445,10 +1454,9 @@ virConnectOpenAuth(const char *name, { virConnectPtr ret = NULL; - VIR_DEBUG("name=%s, auth=%p, flags=%x", NULLSTR(name), auth, flags); - if (virInitialize() < 0) goto error; + VIR_DEBUG("name=%s, auth=%p, flags=%x", NULLSTR(name), auth, flags); virResetLastError(); ret = do_open(name, auth, flags); -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

While auditing error messages in libvirt.c, I found a couple instances that had not been converted to modern error styles, and a few places that failed to dispatch the error through the known-good connection. * src/libvirt.c (virDomainPinEmulator, virDomainGetDiskErrors) (virDomainSendKey, virDomainGetSecurityLabelList) (virDomainGetEmulatorPinInfo): Use typical error reporting. (virConnectGetCPUModelNames, virConnectRegisterCloseCallback) (virConnectUnregisterCloseCallback, virDomainGetUUID): Report error through connection. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 815dd64..33f7078 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -3588,11 +3588,15 @@ virDomainGetUUID(virDomainPtr domain, unsigned char *uuid) virDispatchError(NULL); return -1; } - virCheckNonNullArgReturn(uuid, -1); + virCheckNonNullArgGoto(uuid, error); memcpy(uuid, &domain->uuid[0], VIR_UUID_BUFLEN); return 0; + +error: + virDispatchError(domain->conn); + return -1; } @@ -9866,11 +9870,14 @@ virDomainSendKey(virDomainPtr domain, virResetLastError(); - if (keycodes == NULL || - nkeycodes <= 0 || nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) { - virLibDomainError(VIR_ERR_OPERATION_INVALID, __FUNCTION__); - virDispatchError(NULL); - return -1; + virCheckNonNullArgGoto(keycodes, error); + virCheckPositiveArgGoto(nkeycodes, error); + + if (nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) { + virReportInvalidArg(nkeycodes, + _("nkeycodes in %s must be less than %d"), + __FUNCTION__, VIR_DOMAIN_SEND_KEY_MAX_KEYS); + goto error; } if (!VIR_IS_CONNECTED_DOMAIN(domain)) { @@ -10477,10 +10484,8 @@ virDomainPinEmulator(virDomainPtr domain, unsigned char *cpumap, goto error; } - if ((cpumap == NULL) || (maplen < 1)) { - virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); - goto error; - } + virCheckNonNullArgGoto(cpumap, error); + virCheckPositiveArgGoto(maplen, error); conn = domain->conn; @@ -10537,15 +10542,15 @@ virDomainGetEmulatorPinInfo(virDomainPtr domain, unsigned char *cpumap, return -1; } - if (!cpumap || maplen <= 0) { - virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); - goto error; - } + virCheckNonNullArgGoto(cpumap, error); + virCheckPositiveArgGoto(maplen, error); /* At most one of these two flags should be set. */ if ((flags & VIR_DOMAIN_AFFECT_LIVE) && (flags & VIR_DOMAIN_AFFECT_CONFIG)) { - virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); + virReportInvalidArg(flags, + _("flags 'affect live' and 'affect config' in %s are mutually exclusive"), + __FUNCTION__); goto error; } conn = domain->conn; @@ -10759,10 +10764,7 @@ virDomainGetSecurityLabelList(virDomainPtr domain, return -1; } - if (seclabels == NULL) { - virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); - goto error; - } + virCheckNonNullArgGoto(seclabels, error); conn = domain->conn; @@ -18815,7 +18817,7 @@ virConnectGetCPUModelNames(virConnectPtr conn, const char *arch, char ***models, virDispatchError(NULL); return -1; } - virCheckNonNullArgReturn(arch, -1); + virCheckNonNullArgGoto(arch, error); if (conn->driver->connectGetCPUModelNames) { int ret; @@ -21887,10 +21889,10 @@ virConnectRegisterCloseCallback(virConnectPtr conn, return 0; error: + virDispatchError(conn); virObjectUnlock(conn->closeCallback); virMutexUnlock(&conn->lock); virObjectUnref(conn); - virDispatchError(NULL); return -1; } @@ -21945,9 +21947,9 @@ virConnectUnregisterCloseCallback(virConnectPtr conn, return 0; error: + virDispatchError(conn); virObjectUnlock(conn->closeCallback); virMutexUnlock(&conn->lock); - virDispatchError(NULL); return -1; } @@ -22305,10 +22307,10 @@ virDomainGetDiskErrors(virDomainPtr dom, return -1; } - if ((!errors && maxerrors) || (errors && !maxerrors)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - goto error; - } + if (maxerrors) + virCheckNonNullArgGoto(errors, error); + else + virCheckNullArgGoto(errors, error); if (dom->conn->driver->domainGetDiskErrors) { int ret = dom->conn->driver->domainGetDiskErrors(dom, errors, -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
While auditing error messages in libvirt.c, I found a couple instances that had not been converted to modern error styles, and a few places that failed to dispatch the error through the known-good connection.
* src/libvirt.c (virDomainPinEmulator, virDomainGetDiskErrors) (virDomainSendKey, virDomainGetSecurityLabelList) (virDomainGetEmulatorPinInfo): Use typical error reporting. (virConnectGetCPUModelNames, virConnectRegisterCloseCallback) (virConnectUnregisterCloseCallback, virDomainGetUUID): Report error through connection.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 815dd64..33f7078 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -3588,11 +3588,15 @@ virDomainGetUUID(virDomainPtr domain, unsigned char *uuid) virDispatchError(NULL); return -1; } - virCheckNonNullArgReturn(uuid, -1); + virCheckNonNullArgGoto(uuid, error);
memcpy(uuid, &domain->uuid[0], VIR_UUID_BUFLEN);
return 0; + +error: + virDispatchError(domain->conn); + return -1; }
@@ -9866,11 +9870,14 @@ virDomainSendKey(virDomainPtr domain,
virResetLastError();
- if (keycodes == NULL || - nkeycodes <= 0 || nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) { - virLibDomainError(VIR_ERR_OPERATION_INVALID, __FUNCTION__); - virDispatchError(NULL); - return -1; + virCheckNonNullArgGoto(keycodes, error); + virCheckPositiveArgGoto(nkeycodes, error); + + if (nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) { + virReportInvalidArg(nkeycodes, + _("nkeycodes in %s must be less than %d"),
technically... less than or equal to ...
+ __FUNCTION__, VIR_DOMAIN_SEND_KEY_MAX_KEYS); + goto error; }
I think the above code may need to move after the next two domain checks (although looking forward, I realize it may be irrelevant)... If domain is NULL at the goto error above, then the domain->conn deref in error: will cause more havoc.
if (!VIR_IS_CONNECTED_DOMAIN(domain)) { @@ -10477,10 +10484,8 @@ virDomainPinEmulator(virDomainPtr domain, unsigned char *cpumap, goto error; }
- if ((cpumap == NULL) || (maplen < 1)) { - virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); - goto error; - } + virCheckNonNullArgGoto(cpumap, error); + virCheckPositiveArgGoto(maplen, error);
conn = domain->conn;
@@ -10537,15 +10542,15 @@ virDomainGetEmulatorPinInfo(virDomainPtr domain, unsigned char *cpumap, return -1; }
- if (!cpumap || maplen <= 0) { - virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); - goto error; - } + virCheckNonNullArgGoto(cpumap, error); + virCheckPositiveArgGoto(maplen, error);
/* At most one of these two flags should be set. */ if ((flags & VIR_DOMAIN_AFFECT_LIVE) && (flags & VIR_DOMAIN_AFFECT_CONFIG)) { - virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); + virReportInvalidArg(flags, + _("flags 'affect live' and 'affect config' in %s are mutually exclusive"), + __FUNCTION__);
The new error message is longer than 80 columns.. split across multiple lines. ACK with nits. John
goto error; } conn = domain->conn; @@ -10759,10 +10764,7 @@ virDomainGetSecurityLabelList(virDomainPtr domain, return -1; }
- if (seclabels == NULL) { - virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); - goto error; - } + virCheckNonNullArgGoto(seclabels, error);
conn = domain->conn;
@@ -18815,7 +18817,7 @@ virConnectGetCPUModelNames(virConnectPtr conn, const char *arch, char ***models, virDispatchError(NULL); return -1; } - virCheckNonNullArgReturn(arch, -1); + virCheckNonNullArgGoto(arch, error);
if (conn->driver->connectGetCPUModelNames) { int ret; @@ -21887,10 +21889,10 @@ virConnectRegisterCloseCallback(virConnectPtr conn, return 0;
error: + virDispatchError(conn); virObjectUnlock(conn->closeCallback); virMutexUnlock(&conn->lock); virObjectUnref(conn); - virDispatchError(NULL); return -1; }
@@ -21945,9 +21947,9 @@ virConnectUnregisterCloseCallback(virConnectPtr conn, return 0;
error: + virDispatchError(conn); virObjectUnlock(conn->closeCallback); virMutexUnlock(&conn->lock); - virDispatchError(NULL); return -1; }
@@ -22305,10 +22307,10 @@ virDomainGetDiskErrors(virDomainPtr dom, return -1; }
- if ((!errors && maxerrors) || (errors && !maxerrors)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - goto error; - } + if (maxerrors) + virCheckNonNullArgGoto(errors, error); + else + virCheckNullArgGoto(errors, error);
if (dom->conn->driver->domainGetDiskErrors) { int ret = dom->conn->driver->domainGetDiskErrors(dom, errors,

On 01/02/2014 11:16 AM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
While auditing error messages in libvirt.c, I found a couple instances that had not been converted to modern error styles, and a few places that failed to dispatch the error through the known-good connection.
* src/libvirt.c (virDomainPinEmulator, virDomainGetDiskErrors) (virDomainSendKey, virDomainGetSecurityLabelList) (virDomainGetEmulatorPinInfo): Use typical error reporting. (virConnectGetCPUModelNames, virConnectRegisterCloseCallback) (virConnectUnregisterCloseCallback, virDomainGetUUID): Report error through connection.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-)
virResetLastError();
- if (keycodes == NULL || - nkeycodes <= 0 || nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) { - virLibDomainError(VIR_ERR_OPERATION_INVALID, __FUNCTION__); - virDispatchError(NULL); - return -1; + virCheckNonNullArgGoto(keycodes, error); + virCheckPositiveArgGoto(nkeycodes, error); + + if (nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) { + virReportInvalidArg(nkeycodes, + _("nkeycodes in %s must be less than %d"),
technically...
less than or equal to ...
Indeed.
+ __FUNCTION__, VIR_DOMAIN_SEND_KEY_MAX_KEYS); + goto error; }
I think the above code may need to move after the next two domain checks (although looking forward, I realize it may be irrelevant)...
If domain is NULL at the goto error above, then the domain->conn deref in error: will cause more havoc.
Yes, I ended up fixing it later in the series; but you have a point about bisectability not introducing known temporary bugs. I'll hoist that fix into this patch.
+ virReportInvalidArg(flags, + _("flags 'affect live' and 'affect config' in %s are mutually exclusive"), + __FUNCTION__);
The new error message is longer than 80 columns.. split across multiple lines.
Copied and pasted from elsewhere, but as that is a style issue, fixing all such instances is still within the bounds of this patch.
ACK with nits.
Here's what I squashed in before pushing... On second thought, it makes the content changes harder to find, so I resplit this patch and did the line wrapping in its own patch, then pushed both patches (line wrapping under the trivial rule). Pushed. diff --git i/src/libvirt.c w/src/libvirt.c index 33538f4..c259d2f 100644 --- i/src/libvirt.c +++ w/src/libvirt.c @@ -2831,7 +2831,8 @@ virDomainSaveFlags(virDomainPtr domain, const char *to, if ((flags & VIR_DOMAIN_SAVE_RUNNING) && (flags & VIR_DOMAIN_SAVE_PAUSED)) { virReportInvalidArg(flags, "%s", - _("running and paused flags are mutually exclusive")); + _("running and paused flags are mutually " + "exclusive")); goto error; } @@ -2971,7 +2972,8 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml, if ((flags & VIR_DOMAIN_SAVE_RUNNING) && (flags & VIR_DOMAIN_SAVE_PAUSED)) { virReportInvalidArg(flags, "%s", - _("running and paused flags are mutually exclusive")); + _("running and paused flags are mutually " + "exclusive")); goto error; } @@ -3122,7 +3124,8 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file, if ((flags & VIR_DOMAIN_SAVE_RUNNING) && (flags & VIR_DOMAIN_SAVE_PAUSED)) { virReportInvalidArg(flags, "%s", - _("running and paused flags are mutually exclusive")); + _("running and paused flags are mutually " + "exclusive")); goto error; } @@ -4163,7 +4166,8 @@ virDomainGetMemoryParameters(virDomainPtr domain, if ((flags & VIR_DOMAIN_AFFECT_LIVE) && (flags & VIR_DOMAIN_AFFECT_CONFIG)) { virReportInvalidArg(flags, - _("flags 'affect live' and 'affect config' in %s are mutually exclusive"), + _("flags 'affect live' and 'affect config' in %s " + "are mutually exclusive"), __FUNCTION__); goto error; } @@ -4428,7 +4432,8 @@ virDomainGetBlkioParameters(virDomainPtr domain, if ((flags & VIR_DOMAIN_AFFECT_LIVE) && (flags & VIR_DOMAIN_AFFECT_CONFIG)) { virReportInvalidArg(flags, - _("flags 'affect live' and 'affect config' in %s are mutually exclusive"), + _("flags 'affect live' and 'affect config' in %s " + "are mutually exclusive"), __FUNCTION__); goto error; } @@ -7738,7 +7743,8 @@ virNodeGetCPUStats(virConnectPtr conn, virCheckNonNegativeArgGoto(*nparams, error); if (cpuNum < 0 && cpuNum != VIR_NODE_CPU_STATS_ALL_CPUS) { virReportInvalidArg(cpuNum, - _("cpuNum in %s only accepts %d as a negative value"), + _("cpuNum in %s only accepts %d as a negative " + "value"), __FUNCTION__, VIR_NODE_CPU_STATS_ALL_CPUS); goto error; } @@ -7829,7 +7835,8 @@ virNodeGetMemoryStats(virConnectPtr conn, virCheckNonNegativeArgGoto(*nparams, error); if (cellNum < 0 && cellNum != VIR_NODE_MEMORY_STATS_ALL_CELLS) { virReportInvalidArg(cpuNum, - _("cellNum in %s only accepts %d as a negative value"), + _("cellNum in %s only accepts %d as a negative " + "value"), __FUNCTION__, VIR_NODE_MEMORY_STATS_ALL_CELLS); goto error; } @@ -8241,7 +8248,8 @@ virDomainGetSchedulerParametersFlags(virDomainPtr domain, if ((flags & VIR_DOMAIN_AFFECT_LIVE) && (flags & VIR_DOMAIN_AFFECT_CONFIG)) { virReportInvalidArg(flags, - _("flags 'affect live' and 'affect config' in %s are mutually exclusive"), + _("flags 'affect live' and 'affect config' in %s " + "are mutually exclusive"), __FUNCTION__); goto error; } @@ -9070,7 +9078,8 @@ virDomainMemoryPeek(virDomainPtr dom, /* Exactly one of these two flags must be set. */ if (!(flags & VIR_MEMORY_VIRTUAL) == !(flags & VIR_MEMORY_PHYSICAL)) { virReportInvalidArg(flags, - _("flags in %s must include VIR_MEMORY_VIRTUAL or VIR_MEMORY_PHYSICAL"), + _("flags in %s must include VIR_MEMORY_VIRTUAL or " + "VIR_MEMORY_PHYSICAL"), __FUNCTION__); goto error; } @@ -9877,21 +9886,22 @@ virDomainSendKey(virDomainPtr domain, virResetLastError(); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { + virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + virDispatchError(NULL); + return -1; + } + virCheckNonNullArgGoto(keycodes, error); virCheckPositiveArgGoto(nkeycodes, error); if (nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) { virReportInvalidArg(nkeycodes, - _("nkeycodes in %s must be less than %d"), + _("nkeycodes in %s must be <= %d"), __FUNCTION__, VIR_DOMAIN_SEND_KEY_MAX_KEYS); goto error; } - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } if (domain->conn->flags & VIR_CONNECT_RO) { virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); goto error; @@ -10414,7 +10424,8 @@ virDomainGetVcpuPinInfo(virDomainPtr domain, int ncpumaps, if ((flags & VIR_DOMAIN_AFFECT_LIVE) && (flags & VIR_DOMAIN_AFFECT_CONFIG)) { virReportInvalidArg(flags, - _("flags 'affect live' and 'affect config' in %s are mutually exclusive"), + _("flags 'affect live' and 'affect config' in %s " + "are mutually exclusive"), __FUNCTION__); goto error; } @@ -10556,7 +10567,8 @@ virDomainGetEmulatorPinInfo(virDomainPtr domain, unsigned char *cpumap, if ((flags & VIR_DOMAIN_AFFECT_LIVE) && (flags & VIR_DOMAIN_AFFECT_CONFIG)) { virReportInvalidArg(flags, - _("flags 'affect live' and 'affect config' in %s are mutually exclusive"), + _("flags 'affect live' and 'affect config' in %s " + "are mutually exclusive"), __FUNCTION__); goto error; } @@ -10850,7 +10862,8 @@ virDomainSetMetadata(virDomainPtr domain, case VIR_DOMAIN_METADATA_TITLE: if (metadata && strchr(metadata, '\n')) { virReportInvalidArg(metadata, - _("metadata title in %s can't contain newlines"), + _("metadata title in %s can't contain " + "newlines"), __FUNCTION__); goto error; } @@ -10928,7 +10941,8 @@ virDomainGetMetadata(virDomainPtr domain, if ((flags & VIR_DOMAIN_AFFECT_LIVE) && (flags & VIR_DOMAIN_AFFECT_CONFIG)) { virReportInvalidArg(flags, - _("flags 'affect live' and 'affect config' in %s are mutually exclusive"), + _("flags 'affect live' and 'affect config' in %s " + "are mutually exclusive"), __FUNCTION__); goto error; } @@ -15464,7 +15478,8 @@ virStorageVolResize(virStorageVolPtr vol, if (capacity == 0 && !((flags & VIR_STORAGE_VOL_RESIZE_DELTA) || (flags & VIR_STORAGE_VOL_RESIZE_SHRINK))) { virReportInvalidArg(capacity, - _("capacity in %s cannot be zero without 'delta' or 'shrink' flags set"), + _("capacity in %s cannot be zero without 'delta' " + "or 'shrink' flags set"), __FUNCTION__); goto error; } @@ -19610,7 +19625,8 @@ virDomainManagedSave(virDomainPtr dom, unsigned int flags) if ((flags & VIR_DOMAIN_SAVE_RUNNING) && (flags & VIR_DOMAIN_SAVE_PAUSED)) { virReportInvalidArg(flags, - _("running and paused flags in %s are mutually exclusive"), + _("running and paused flags in %s are mutually " + "exclusive"), __FUNCTION__); goto error; } @@ -19937,21 +19953,24 @@ virDomainSnapshotCreateXML(virDomainPtr domain, if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT) && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE)) { virReportInvalidArg(flags, - _("use of 'current' flag in %s requires 'redefine' flag"), + _("use of 'current' flag in %s requires " + "'redefine' flag"), __FUNCTION__); goto error; } if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE) && (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { virReportInvalidArg(flags, - _("'redefine' and 'no metadata' flags in %s are mutually exclusive"), + _("'redefine' and 'no metadata' flags in %s are " + "mutually exclusive"), __FUNCTION__); goto error; } if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE) && (flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT)) { virReportInvalidArg(flags, - _("'redefine' and 'halt' flags in %s are mutually exclusive"), + _("'redefine' and 'halt' flags in %s are mutually " + "exclusive"), __FUNCTION__); goto error; } @@ -20868,7 +20887,8 @@ virDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, if ((flags & VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING) && (flags & VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) { virReportInvalidArg(flags, - _("running and paused flags in %s are mutually exclusive"), + _("running and paused flags in %s are mutually " + "exclusive"), __FUNCTION__); goto error; } @@ -22110,7 +22130,8 @@ virDomainGetBlockIoTune(virDomainPtr dom, if ((flags & VIR_DOMAIN_AFFECT_LIVE) && (flags & VIR_DOMAIN_AFFECT_CONFIG)) { virReportInvalidArg(flags, - _("flags 'affect live' and 'affect config' in %s are mutually exclusive"), + _("flags 'affect live' and 'affect config' in %s " + "are mutually exclusive"), __FUNCTION__); goto error; } -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Several APIs clear out a user input buffer before attempting to populate it; but in a few cases we missed this memset if we detect a reason for an early exit. * src/libvirt.c (virDomainGetInfo, virDomainGetBlockInfo) (virStoragePoolGetInfo, virStorageVolGetInfo) (virDomainGetJobInfo, virDomainGetBlockJobInfo): Move memset before any returns. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 33f7078..7fd6072 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -4461,6 +4461,8 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) virResetLastError(); + memset(info, 0, sizeof(virDomainInfo)); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); @@ -4468,8 +4470,6 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) } virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(virDomainInfo)); - conn = domain->conn; if (conn->driver->domainGetInfo) { @@ -9114,6 +9114,8 @@ virDomainGetBlockInfo(virDomainPtr domain, const char *disk, virResetLastError(); + memset(info, 0, sizeof(virDomainBlockInfo)); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); @@ -9122,8 +9124,6 @@ virDomainGetBlockInfo(virDomainPtr domain, const char *disk, virCheckNonNullArgGoto(disk, error); virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(virDomainBlockInfo)); - conn = domain->conn; if (conn->driver->domainGetBlockInfo) { @@ -14297,6 +14297,8 @@ virStoragePoolGetInfo(virStoragePoolPtr pool, virResetLastError(); + memset(info, 0, sizeof(virStoragePoolInfo)); + if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); virDispatchError(NULL); @@ -14304,8 +14306,6 @@ virStoragePoolGetInfo(virStoragePoolPtr pool, } virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(virStoragePoolInfo)); - conn = pool->conn; if (conn->storageDriver->storagePoolGetInfo) { @@ -15281,6 +15281,8 @@ virStorageVolGetInfo(virStorageVolPtr vol, virResetLastError(); + memset(info, 0, sizeof(virStorageVolInfo)); + if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) { virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); virDispatchError(NULL); @@ -15288,8 +15290,6 @@ virStorageVolGetInfo(virStorageVolPtr vol, } virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(virStorageVolInfo)); - conn = vol->conn; if (conn->storageDriver->storageVolGetInfo){ @@ -18918,6 +18918,8 @@ virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info) virResetLastError(); + memset(info, 0, sizeof(virDomainJobInfo)); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); @@ -18925,8 +18927,6 @@ virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info) } virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(virDomainJobInfo)); - conn = domain->conn; if (conn->driver->domainGetJobInfo) { @@ -21245,6 +21245,8 @@ virDomainGetBlockJobInfo(virDomainPtr dom, const char *disk, virResetLastError(); + memset(info, 0, sizeof(*info)); + if (!VIR_IS_CONNECTED_DOMAIN(dom)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); @@ -21255,8 +21257,6 @@ virDomainGetBlockJobInfo(virDomainPtr dom, const char *disk, virCheckNonNullArgGoto(disk, error); virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(*info)); - if (conn->driver->domainGetBlockJobInfo) { int ret; ret = conn->driver->domainGetBlockJobInfo(dom, disk, info, flags); -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
Several APIs clear out a user input buffer before attempting to populate it; but in a few cases we missed this memset if we detect a reason for an early exit.
* src/libvirt.c (virDomainGetInfo, virDomainGetBlockInfo) (virStoragePoolGetInfo, virStorageVolGetInfo) (virDomainGetJobInfo, virDomainGetBlockJobInfo): Move memset before any returns.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
Not sure any of these are correct... Each of the clear outs is after a check of whether the passed 'info' buffer is non NULL. For each that means you'd potentially have "memset(NULL, 0, sizeof())" John
diff --git a/src/libvirt.c b/src/libvirt.c index 33f7078..7fd6072 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -4461,6 +4461,8 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
virResetLastError();
+ memset(info, 0, sizeof(virDomainInfo)); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); @@ -4468,8 +4470,6 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) } virCheckNonNullArgGoto(info, error);
- memset(info, 0, sizeof(virDomainInfo)); - conn = domain->conn;
if (conn->driver->domainGetInfo) { @@ -9114,6 +9114,8 @@ virDomainGetBlockInfo(virDomainPtr domain, const char *disk,
virResetLastError();
+ memset(info, 0, sizeof(virDomainBlockInfo)); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); @@ -9122,8 +9124,6 @@ virDomainGetBlockInfo(virDomainPtr domain, const char *disk, virCheckNonNullArgGoto(disk, error); virCheckNonNullArgGoto(info, error);
- memset(info, 0, sizeof(virDomainBlockInfo)); - conn = domain->conn;
if (conn->driver->domainGetBlockInfo) { @@ -14297,6 +14297,8 @@ virStoragePoolGetInfo(virStoragePoolPtr pool,
virResetLastError();
+ memset(info, 0, sizeof(virStoragePoolInfo)); + if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); virDispatchError(NULL); @@ -14304,8 +14306,6 @@ virStoragePoolGetInfo(virStoragePoolPtr pool, } virCheckNonNullArgGoto(info, error);
- memset(info, 0, sizeof(virStoragePoolInfo)); - conn = pool->conn;
if (conn->storageDriver->storagePoolGetInfo) { @@ -15281,6 +15281,8 @@ virStorageVolGetInfo(virStorageVolPtr vol,
virResetLastError();
+ memset(info, 0, sizeof(virStorageVolInfo)); + if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) { virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); virDispatchError(NULL); @@ -15288,8 +15290,6 @@ virStorageVolGetInfo(virStorageVolPtr vol, } virCheckNonNullArgGoto(info, error);
- memset(info, 0, sizeof(virStorageVolInfo)); - conn = vol->conn;
if (conn->storageDriver->storageVolGetInfo){ @@ -18918,6 +18918,8 @@ virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info)
virResetLastError();
+ memset(info, 0, sizeof(virDomainJobInfo)); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); @@ -18925,8 +18927,6 @@ virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info) } virCheckNonNullArgGoto(info, error);
- memset(info, 0, sizeof(virDomainJobInfo)); - conn = domain->conn;
if (conn->driver->domainGetJobInfo) { @@ -21245,6 +21245,8 @@ virDomainGetBlockJobInfo(virDomainPtr dom, const char *disk,
virResetLastError();
+ memset(info, 0, sizeof(*info)); + if (!VIR_IS_CONNECTED_DOMAIN(dom)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); @@ -21255,8 +21257,6 @@ virDomainGetBlockJobInfo(virDomainPtr dom, const char *disk, virCheckNonNullArgGoto(disk, error); virCheckNonNullArgGoto(info, error);
- memset(info, 0, sizeof(*info)); - if (conn->driver->domainGetBlockJobInfo) { int ret; ret = conn->driver->domainGetBlockJobInfo(dom, disk, info, flags);

On 01/02/2014 11:24 AM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
Several APIs clear out a user input buffer before attempting to populate it; but in a few cases we missed this memset if we detect a reason for an early exit.
* src/libvirt.c (virDomainGetInfo, virDomainGetBlockInfo) (virStoragePoolGetInfo, virStorageVolGetInfo) (virDomainGetJobInfo, virDomainGetBlockJobInfo): Move memset before any returns.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
Not sure any of these are correct... Each of the clear outs is after a check of whether the passed 'info' buffer is non NULL.
For each that means you'd potentially have "memset(NULL, 0, sizeof())"
Ooh, you make a good point. The caller has a bug in that case, and we could technically argue that they deserve the segfault (passing a bad pointer is the classic case of undefined behavior, and faulting will call attention to their bad code faster than an error code that might be ignored). But just because they deserve it doesn't mean we should do it, especially since it is a change in behavior for sloppy programs that currently get a nice error message but would now crash (we can't detect every single bad pointer, but NULL is a special case that is both more likely than any other bad pointer, and also easy enough to single out). So on the grounds of accommodating existing sloppy use, I'm thinking that it's best to change all of these to make the memset conditional on a non-NULL pointer, but still moving the memset to occur before other early exits (that is, we guarantee that if the buffer is valid, we clear it; and if the buffer is NULL, we guarantee a sane error message). My rework of this patch gets delayed to v2. By the way, the motivation behind this patch is functions like virConnectListAllDomains, which takes pains to ensure *domains is set to NULL regardless of error, but which DID play it safe: virConnectListAllDomains(virConnectPtr conn, virDomainPtr **domains, unsigned int flags) { VIR_DEBUG("conn=%p, domains=%p, flags=%x", conn, domains, flags); virResetLastError(); if (domains) *domains = NULL; -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

We document that calling any public API wipes out all prior libvirt errors in the same thread; but weren't obeying this style in a few functions. * src/libvirt.c (virGetVersion, virConnectRef, virDomainRef) (virDomainGetSecurityLabel, virDomainGetSecurityLabelList) (virDomainSetMetadata, virDomainGetMetadata) (virNodeGetSecurityModel, virNetworkRef, virInterfaceRef) (virStoragePoolRef, virStorageVolRef, virNodeDeviceGetName) (virNodeDeviceRef, virSecretRef, virStreamRef, virNWFilterRef) (virDomainSnapshotRef): Reset error on entrance. (do_open): Drop redundant error reset. * src/libvirt-qemu.c (virDomainQemuAgentCommand): Likewise. * src/libvirt-lxc.c (virDomainLxcEnterNamespace) (virDomainLxcEnterSecurityLabel): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt-lxc.c | 4 ++++ src/libvirt-qemu.c | 4 ++++ src/libvirt.c | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index 7ffed3e..e7b4198 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -142,6 +142,8 @@ virDomainLxcEnterNamespace(virDomainPtr domain, "noldfdlist=%p, oldfdlist=%p, flags=%x", nfdlist, fdlist, noldfdlist, oldfdlist, flags); + virResetLastError(); + virCheckFlagsGoto(0, error); if (noldfdlist && oldfdlist) { @@ -203,6 +205,8 @@ virDomainLxcEnterSecurityLabel(virSecurityModelPtr model, VIR_DEBUG("model=%p, label=%p, oldlabel=%p, flags=%x", model, label, oldlabel, flags); + virResetLastError(); + virCheckFlagsGoto(0, error); virCheckNonNullArgGoto(model, error); diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 2fa5522..71148f7 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -112,6 +112,7 @@ error: return -1; } + /** * virDomainQemuAttach: * @conn: pointer to a hypervisor connection @@ -186,6 +187,7 @@ error: return NULL; } + /** * virDomainQemuAgentCommand: * @domain: a domain object @@ -217,6 +219,8 @@ virDomainQemuAgentCommand(virDomainPtr domain, VIR_DOMAIN_DEBUG(domain, "cmd=%s, timeout=%d, flags=%x", cmd, timeout, flags); + virResetLastError(); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); diff --git a/src/libvirt.c b/src/libvirt.c index 7fd6072..cd1112a 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -918,6 +918,7 @@ virGetVersion(unsigned long *libVer, const char *type ATTRIBUTE_UNUSED, if (virInitialize() < 0) goto error; + virResetLastError(); if (libVer == NULL) goto error; *libVer = LIBVIR_VERSION_NUMBER; @@ -1098,8 +1099,6 @@ do_open(const char *name, virConnectPtr ret; virConfPtr conf = NULL; - virResetLastError(); - ret = virGetConnect(); if (ret == NULL) return NULL; @@ -1535,6 +1534,8 @@ virConnectRef(virConnectPtr conn) { VIR_DEBUG("conn=%p refs=%d", conn, conn ? conn->object.u.s.refs : 0); + virResetLastError(); + if ((!VIR_IS_CONNECT(conn))) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); virDispatchError(NULL); @@ -2463,6 +2464,8 @@ virDomainRef(virDomainPtr domain) { VIR_DOMAIN_DEBUG(domain, "refs=%d", domain ? domain->object.u.s.refs : 0); + virResetLastError(); + if ((!VIR_IS_CONNECTED_DOMAIN(domain))) { virLibConnError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); @@ -10712,6 +10715,8 @@ virDomainGetSecurityLabel(virDomainPtr domain, virSecurityLabelPtr seclabel) VIR_DOMAIN_DEBUG(domain, "seclabel=%p", seclabel); + virResetLastError(); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); @@ -10758,6 +10763,8 @@ virDomainGetSecurityLabelList(virDomainPtr domain, VIR_DOMAIN_DEBUG(domain, "seclabels=%p", seclabels); + virResetLastError(); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); virDispatchError(NULL); @@ -10827,6 +10834,8 @@ virDomainSetMetadata(virDomainPtr domain, type, NULLSTR(metadata), NULLSTR(key), NULLSTR(uri), flags); + virResetLastError(); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); goto error; @@ -10913,6 +10922,8 @@ virDomainGetMetadata(virDomainPtr domain, VIR_DOMAIN_DEBUG(domain, "type=%d, uri='%s', flags=%x", type, NULLSTR(uri), flags); + virResetLastError(); + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); goto error; @@ -10972,6 +10983,8 @@ virNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel) { VIR_DEBUG("conn=%p secmodel=%p", conn, secmodel); + virResetLastError(); + if (!VIR_IS_CONNECT(conn)) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); virDispatchError(NULL); @@ -12085,6 +12098,8 @@ virNetworkRef(virNetworkPtr network) VIR_DEBUG("network=%p refs=%d", network, network ? network->object.u.s.refs : 0); + virResetLastError(); + if ((!VIR_IS_CONNECTED_NETWORK(network))) { virLibConnError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); virDispatchError(NULL); @@ -13054,6 +13069,8 @@ virInterfaceRef(virInterfacePtr iface) { VIR_DEBUG("iface=%p refs=%d", iface, iface ? iface->object.u.s.refs : 0); + virResetLastError(); + if ((!VIR_IS_CONNECTED_INTERFACE(iface))) { virLibConnError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); virDispatchError(NULL); @@ -14125,6 +14142,8 @@ virStoragePoolRef(virStoragePoolPtr pool) { VIR_DEBUG("pool=%p refs=%d", pool, pool ? pool->object.u.s.refs : 0); + virResetLastError(); + if ((!VIR_IS_CONNECTED_STORAGE_POOL(pool))) { virLibConnError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); virDispatchError(NULL); @@ -15252,6 +15271,8 @@ virStorageVolRef(virStorageVolPtr vol) { VIR_DEBUG("vol=%p refs=%d", vol, vol ? vol->object.u.s.refs : 0); + virResetLastError(); + if ((!VIR_IS_CONNECTED_STORAGE_VOL(vol))) { virLibConnError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); virDispatchError(NULL); @@ -15784,6 +15805,8 @@ const char *virNodeDeviceGetName(virNodeDevicePtr dev) { VIR_DEBUG("dev=%p, conn=%p", dev, dev ? dev->conn : NULL); + virResetLastError(); + if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); virDispatchError(NULL); @@ -15958,6 +15981,8 @@ virNodeDeviceRef(virNodeDevicePtr dev) { VIR_DEBUG("dev=%p refs=%d", dev, dev ? dev->object.u.s.refs : 0); + virResetLastError(); + if ((!VIR_IS_CONNECTED_NODE_DEVICE(dev))) { virLibConnError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); virDispatchError(NULL); @@ -17087,6 +17112,8 @@ virSecretRef(virSecretPtr secret) VIR_DEBUG("secret=%p refs=%d", secret, secret ? secret->object.u.s.refs : 0); + virResetLastError(); + if (!VIR_IS_CONNECTED_SECRET(secret)) { virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); virDispatchError(NULL); @@ -17184,6 +17211,8 @@ virStreamRef(virStreamPtr stream) VIR_DEBUG("stream=%p refs=%d", stream, stream ? stream->object.u.s.refs : 0); + virResetLastError(); + if ((!VIR_IS_CONNECTED_STREAM(stream))) { virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); virDispatchError(NULL); @@ -18624,6 +18653,8 @@ virNWFilterRef(virNWFilterPtr nwfilter) VIR_DEBUG("nwfilter=%p refs=%d", nwfilter, nwfilter ? nwfilter->object.u.s.refs : 0); + virResetLastError(); + if ((!VIR_IS_CONNECTED_NWFILTER(nwfilter))) { virLibConnError(VIR_ERR_INVALID_NWFILTER, __FUNCTION__); virDispatchError(NULL); @@ -20964,6 +20995,8 @@ virDomainSnapshotRef(virDomainSnapshotPtr snapshot) VIR_DEBUG("snapshot=%p, refs=%d", snapshot, snapshot ? snapshot->object.u.s.refs : 0); + virResetLastError(); + if ((!VIR_IS_DOMAIN_SNAPSHOT(snapshot))) { virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, __FUNCTION__); -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
We document that calling any public API wipes out all prior libvirt errors in the same thread; but weren't obeying this style in a few functions.
* src/libvirt.c (virGetVersion, virConnectRef, virDomainRef) (virDomainGetSecurityLabel, virDomainGetSecurityLabelList) (virDomainSetMetadata, virDomainGetMetadata) (virNodeGetSecurityModel, virNetworkRef, virInterfaceRef) (virStoragePoolRef, virStorageVolRef, virNodeDeviceGetName) (virNodeDeviceRef, virSecretRef, virStreamRef, virNWFilterRef) (virDomainSnapshotRef): Reset error on entrance. (do_open): Drop redundant error reset. * src/libvirt-qemu.c (virDomainQemuAgentCommand): Likewise. * src/libvirt-lxc.c (virDomainLxcEnterNamespace) (virDomainLxcEnterSecurityLabel): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt-lxc.c | 4 ++++ src/libvirt-qemu.c | 4 ++++ src/libvirt.c | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-)
ACK just making sure - is there any side effect to calls to virConnectRef() being called through the lxc reboot or qemu reconnect paths? John

On 01/02/2014 12:11 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
We document that calling any public API wipes out all prior libvirt errors in the same thread; but weren't obeying this style in a few functions.
* src/libvirt.c (virGetVersion, virConnectRef, virDomainRef) (virDomainGetSecurityLabel, virDomainGetSecurityLabelList) (virDomainSetMetadata, virDomainGetMetadata) (virNodeGetSecurityModel, virNetworkRef, virInterfaceRef) (virStoragePoolRef, virStorageVolRef, virNodeDeviceGetName) (virNodeDeviceRef, virSecretRef, virStreamRef, virNWFilterRef) (virDomainSnapshotRef): Reset error on entrance. (do_open): Drop redundant error reset. * src/libvirt-qemu.c (virDomainQemuAgentCommand): Likewise. * src/libvirt-lxc.c (virDomainLxcEnterNamespace) (virDomainLxcEnterSecurityLabel): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt-lxc.c | 4 ++++ src/libvirt-qemu.c | 4 ++++ src/libvirt.c | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-)
ACK
just making sure - is there any side effect to calls to virConnectRef() being called through the lxc reboot or qemu reconnect paths?
Wow, I didn't even think to grep for those. And you are right - those are cases of nested public API calls (which we want to avoid where possible); they should ideally be using virObjectRef() instead of the public call (it still doesn't help our nested use of virConnectOpen() in those same functions, but fixing that is a bigger task that would need a separate patch, if we decide it is needed). For this particular patch, there is no change in behavior (we only attempt the virConnectOpen() if we have been successful to that point, so resetting errors has no impact), so I pushed it as is, after tweaking the commit message to mention this discussion. But I'll add a followup patch to my v2 series that tries to clean up this and other nested of virConnectRef/virConnectClose to instead use virObjectRef/virObjectUnref. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Having one API call into another is generally not good; among other issues, it gives confusing logs, and is not quite as efficient. This fixes several instances, but not all: we still have instances in both libvirt.c and in backend hypervisors (lxc and qemu) calling the public virTypedParamsGetString and friends, which dispatch errors immediately. I'm not sure if it is worth trying to clean that up in a separate patch (such a cleanup may be easiest by separating the public function into a wrapper around the internal, then tweaking internal.h so that internal users directly use the internal function). * src/libvirt.c (virDomainGetUUIDString, virNetworkGetUUIDString) (virStoragePoolGetUUIDString, virSecretGetUUIDString) (virNWFilterGetUUIDString): Avoid nested public API call. * src/util/virtypedparam.c (virTypedParamsReplaceString): Don't dispatch errors here. (virTypedParamsGet): No need to reset errors. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 31 +++++-------------------------- src/util/virtypedparam.c | 14 +++++++++----- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index cd1112a..587690f 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -3616,8 +3616,6 @@ error: int virDomainGetUUIDString(virDomainPtr domain, char *buf) { - unsigned char uuid[VIR_UUID_BUFLEN]; - VIR_DOMAIN_DEBUG(domain, "buf=%p", buf); virResetLastError(); @@ -3629,10 +3627,7 @@ virDomainGetUUIDString(virDomainPtr domain, char *buf) } virCheckNonNullArgGoto(buf, error); - if (virDomainGetUUID(domain, &uuid[0])) - goto error; - - virUUIDFormat(uuid, buf); + virUUIDFormat(domain->uuid, buf); return 0; error: @@ -12181,7 +12176,6 @@ error: int virNetworkGetUUIDString(virNetworkPtr network, char *buf) { - unsigned char uuid[VIR_UUID_BUFLEN]; VIR_DEBUG("network=%p, buf=%p", network, buf); virResetLastError(); @@ -12193,10 +12187,7 @@ virNetworkGetUUIDString(virNetworkPtr network, char *buf) } virCheckNonNullArgGoto(buf, error); - if (virNetworkGetUUID(network, &uuid[0])) - goto error; - - virUUIDFormat(uuid, buf); + virUUIDFormat(network->uuid, buf); return 0; error: @@ -14273,7 +14264,6 @@ int virStoragePoolGetUUIDString(virStoragePoolPtr pool, char *buf) { - unsigned char uuid[VIR_UUID_BUFLEN]; VIR_DEBUG("pool=%p, buf=%p", pool, buf); virResetLastError(); @@ -14285,10 +14275,7 @@ virStoragePoolGetUUIDString(virStoragePoolPtr pool, } virCheckNonNullArgGoto(buf, error); - if (virStoragePoolGetUUID(pool, &uuid[0])) - goto error; - - virUUIDFormat(uuid, buf); + virUUIDFormat(pool->uuid, buf); return 0; error: @@ -16816,7 +16803,6 @@ error: int virSecretGetUUIDString(virSecretPtr secret, char *buf) { - unsigned char uuid[VIR_UUID_BUFLEN]; VIR_DEBUG("secret=%p, buf=%p", secret, buf); virResetLastError(); @@ -16828,10 +16814,7 @@ virSecretGetUUIDString(virSecretPtr secret, char *buf) } virCheckNonNullArgGoto(buf, error); - if (virSecretGetUUID(secret, &uuid[0])) - goto error; - - virUUIDFormat(uuid, buf); + virUUIDFormat(secret->uuid, buf); return 0; error: @@ -18472,7 +18455,6 @@ error: int virNWFilterGetUUIDString(virNWFilterPtr nwfilter, char *buf) { - unsigned char uuid[VIR_UUID_BUFLEN]; VIR_DEBUG("nwfilter=%p, buf=%p", nwfilter, buf); virResetLastError(); @@ -18484,10 +18466,7 @@ virNWFilterGetUUIDString(virNWFilterPtr nwfilter, char *buf) } virCheckNonNullArgGoto(buf, error); - if (virNWFilterGetUUID(nwfilter, &uuid[0])) - goto error; - - virUUIDFormat(uuid, buf); + virUUIDFormat(nwfilter->uuid, buf); return 0; error: diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 5334a9f..26fb78c 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -1,7 +1,7 @@ /* * virtypedparam.c: utility functions for dealing with virTypedParameters * - * Copyright (C) 2011-2012 Red Hat, Inc. + * Copyright (C) 2011-2013 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -41,6 +41,12 @@ VIR_ENUM_IMPL(virTypedParameter, VIR_TYPED_PARAM_LAST, "boolean", "string") +/* When editing this file, ensure that public exported functions + * (those in libvirt_public.syms) either trigger no errors, or else + * reset error on entrance and call virDispatchError() on exit; while + * internal utility functions (those in libvirt_private.syms) may + * report errors that the caller will dispatch. */ + /* Validate that PARAMS contains only recognized parameter names with * correct types, and with no duplicates. Pass in as many name/type * pairs as appropriate, and pass NULL to end the list of accepted @@ -346,8 +352,6 @@ virTypedParamsReplaceString(virTypedParameterPtr *params, size_t n = *nparams; virTypedParameterPtr param; - virResetLastError(); - param = virTypedParamsGet(*params, n, name); if (param) { if (param->type != VIR_TYPED_PARAM_STRING) { @@ -378,7 +382,6 @@ virTypedParamsReplaceString(virTypedParameterPtr *params, return 0; error: - virDispatchError(NULL); return -1; } @@ -426,6 +429,7 @@ virTypedParamsCopy(virTypedParameterPtr *dst, * Finds typed parameter called @name. * * Returns pointer to the parameter or NULL if it does not exist in @params. + * This function does not raise an error, even when returning NULL. */ virTypedParameterPtr virTypedParamsGet(virTypedParameterPtr params, @@ -434,7 +438,7 @@ virTypedParamsGet(virTypedParameterPtr params, { size_t i; - virResetLastError(); + /* No need to reset errors, since this function doesn't report any. */ if (!params || !name) return NULL; -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
Having one API call into another is generally not good; among other issues, it gives confusing logs, and is not quite as efficient.
This fixes several instances, but not all: we still have instances in both libvirt.c and in backend hypervisors (lxc and qemu) calling the public virTypedParamsGetString and friends, which dispatch errors immediately. I'm not sure if it is worth trying to clean that up in a separate patch (such a cleanup may be easiest by separating the public function into a wrapper around the internal, then tweaking internal.h so that internal users directly use the internal function).
* src/libvirt.c (virDomainGetUUIDString, virNetworkGetUUIDString) (virStoragePoolGetUUIDString, virSecretGetUUIDString) (virNWFilterGetUUIDString): Avoid nested public API call. * src/util/virtypedparam.c (virTypedParamsReplaceString): Don't dispatch errors here. (virTypedParamsGet): No need to reset errors.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 31 +++++-------------------------- src/util/virtypedparam.c | 14 +++++++++----- 2 files changed, 14 insertions(+), 31 deletions(-)
ACK Although I do note that virTypedParamsGetBoolean() has a slightly different call flow than other similar functions... That is usually it's virResetLastError() virTypedParamsGet() VIR_TYPED_PARAM_CHECK_TYPE() but, GetBoolean swaps ResetLast and TypedParamsGet() Since this is a cleanup of sorts - just thought it may be useful to be consistent. John

On 01/02/2014 12:50 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
Having one API call into another is generally not good; among other issues, it gives confusing logs, and is not quite as efficient.
* src/libvirt.c (virDomainGetUUIDString, virNetworkGetUUIDString) (virStoragePoolGetUUIDString, virSecretGetUUIDString) (virNWFilterGetUUIDString): Avoid nested public API call. * src/util/virtypedparam.c (virTypedParamsReplaceString): Don't dispatch errors here. (virTypedParamsGet): No need to reset errors.
ACK
Although I do note that virTypedParamsGetBoolean() has a slightly different call flow than other similar functions...
Sure, I can fix that. Here's what I squashed when pushing. diff --git i/src/util/virtypedparam.c w/src/util/virtypedparam.c index 26fb78c..7e8ea7f 100644 --- i/src/util/virtypedparam.c +++ w/src/util/virtypedparam.c @@ -1,7 +1,7 @@ /* * virtypedparam.c: utility functions for dealing with virTypedParameters * - * Copyright (C) 2011-2013 Red Hat, Inc. + * Copyright (C) 2011-2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -668,11 +668,11 @@ virTypedParamsGetBoolean(virTypedParameterPtr params, { virTypedParameterPtr param; + virResetLastError(); + if (!(param = virTypedParamsGet(params, nparams, name))) return 0; - virResetLastError(); - VIR_TYPED_PARAM_CHECK_TYPE(VIR_TYPED_PARAM_BOOLEAN); if (value) *value = !!param->value.b; -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

We weren't very consistent in our use of VIR_ERR_NO_SUPPORT; many users just passed __FUNCTION__ on, while others passed "%s" to silence over-eager compilers that warn about __FUNCTION__ not containing any %. It's nicer to route all these uses through a single macro, so that if we ever need to change the reporting, we can do it in one place. I verified that 'virsh -c test:///default qemu-monitor-command test foo' gives the same error message before and after this patch: error: this function is not supported by the connection driver: virDomainQemuMonitorCommand Note that in libvirt.c, we were inconsistent on whether virDomain* API used virLibConnError() (with VIR_FROM_NONE) or virLibDomainError() (with VIR_FROM_DOMAIN); this patch unifies these errors to all use VIR_FROM_NONE, on the grounds that it is unlikely that a caller learning that a call is unimplemented can do anything in particular with extra knowledge of which error domain it belongs to. * src/util/virerror.h (virReportUnsupportedError): New macro. * src/libvirt.c: Use it. * src/libvirt-qemu.c: Likewise. * src/libvirt-lxc.c: Likewise. * src/lxc/lxc_driver.c: Likewise. * src/security/security_manager.c: Likewise. * src/util/virinitctl.c: Likewise. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt-lxc.c | 2 +- src/libvirt-qemu.c | 7 +- src/libvirt.c | 612 ++++++++++++++++++++-------------------- src/lxc/lxc_driver.c | 2 +- src/security/security_manager.c | 46 +-- src/util/virerror.h | 5 + src/util/virinitctl.c | 4 +- src/xen/xen_driver.c | 8 +- 8 files changed, 345 insertions(+), 341 deletions(-) diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index e7b4198..5bf5f56 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -99,7 +99,7 @@ virDomainLxcOpenNamespace(virDomainPtr domain, return ret; } - virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 71148f7..79486fd 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -105,7 +105,7 @@ virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, return ret; } - virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -180,7 +180,7 @@ virDomainQemuAttach(virConnectPtr conn, return ret; } - virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -242,9 +242,8 @@ virDomainQemuAgentCommand(virDomainPtr domain, return ret; } - virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); - /* Copy to connection error object for back compatibility */ error: virDispatchError(conn); return NULL; diff --git a/src/libvirt.c b/src/libvirt.c index 587690f..693adbf 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1648,7 +1648,7 @@ virConnectGetVersion(virConnectPtr conn, unsigned long *hvVer) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -1732,7 +1732,7 @@ virConnectGetHostname(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -1813,7 +1813,7 @@ virConnectGetSysinfo(virConnectPtr conn, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -1853,7 +1853,7 @@ virConnectGetMaxVcpus(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -1900,7 +1900,7 @@ virConnectListDomains(virConnectPtr conn, int *ids, int maxids) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -1935,7 +1935,7 @@ virConnectNumOfDomains(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -2025,7 +2025,7 @@ virDomainCreateXML(virConnectPtr conn, const char *xmlDesc, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return NULL; @@ -2099,7 +2099,7 @@ virDomainCreateXMLWithFiles(virConnectPtr conn, const char *xmlDesc, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return NULL; @@ -2160,7 +2160,7 @@ virDomainLookupByID(virConnectPtr conn, int id) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -2200,7 +2200,7 @@ virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -2280,7 +2280,7 @@ virDomainLookupByName(virConnectPtr conn, const char *name) return dom; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -2341,7 +2341,7 @@ virDomainDestroy(virDomainPtr domain) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -2408,7 +2408,7 @@ virDomainDestroyFlags(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -2520,7 +2520,7 @@ virDomainSuspend(virDomainPtr domain) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -2569,7 +2569,7 @@ virDomainResume(virDomainPtr domain) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -2638,7 +2638,7 @@ virDomainPMSuspendForDuration(virDomainPtr dom, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -2689,7 +2689,7 @@ virDomainPMWakeup(virDomainPtr dom, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -2754,7 +2754,7 @@ virDomainSave(virDomainPtr domain, const char *to) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -2850,7 +2850,7 @@ virDomainSaveFlags(virDomainPtr domain, const char *to, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -2907,7 +2907,7 @@ virDomainRestore(virConnectPtr conn, const char *from) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -2991,7 +2991,7 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -3060,7 +3060,7 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -3142,7 +3142,7 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -3234,7 +3234,7 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -3300,7 +3300,7 @@ virDomainScreenshot(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -3357,7 +3357,7 @@ virDomainShutdown(virDomainPtr domain) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -3421,7 +3421,7 @@ virDomainShutdownFlags(virDomainPtr domain, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -3486,7 +3486,7 @@ virDomainReboot(virDomainPtr domain, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -3537,7 +3537,7 @@ virDomainReset(virDomainPtr domain, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -3694,7 +3694,7 @@ virDomainGetOSType(virDomainPtr domain) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -3743,7 +3743,7 @@ virDomainGetMaxMemory(virDomainPtr domain) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -3797,7 +3797,7 @@ virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -3850,7 +3850,7 @@ virDomainSetMemory(virDomainPtr domain, unsigned long memory) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -3915,7 +3915,7 @@ virDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -3979,7 +3979,7 @@ virDomainSetMemoryStatsPeriod(virDomainPtr domain, int period, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -4080,7 +4080,7 @@ virDomainSetMemoryParameters(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -4166,7 +4166,7 @@ virDomainGetMemoryParameters(virDomainPtr domain, goto error; return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -4225,7 +4225,7 @@ virDomainSetNumaParameters(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -4295,7 +4295,7 @@ virDomainGetNumaParameters(virDomainPtr domain, goto error; return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -4354,7 +4354,7 @@ virDomainSetBlkioParameters(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -4431,7 +4431,7 @@ virDomainGetBlkioParameters(virDomainPtr domain, goto error; return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -4478,7 +4478,7 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -4528,7 +4528,7 @@ virDomainGetState(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -4574,7 +4574,7 @@ virDomainGetControlInfo(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -4634,7 +4634,7 @@ virDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -4690,7 +4690,7 @@ char *virConnectDomainXMLFromNative(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -4746,7 +4746,7 @@ char *virConnectDomainXMLToNative(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -5440,7 +5440,7 @@ virDomainMigrateDirect(virDomainPtr domain, bandwidth); if (!domain->conn->driver->domainMigratePerform) { - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); virDispatchError(domain->conn); return -1; } @@ -5645,7 +5645,7 @@ virDomainMigrate(virDomainPtr domain, ddomain = virDomainLookupByName(dconn, dname ? dname : domain->name); } else { /* This driver does not support peer to peer migration */ - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); goto error; } } else { @@ -5692,7 +5692,7 @@ virDomainMigrate(virDomainPtr domain, dname, uri, bandwidth); } else { /* This driver does not support any migration method */ - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); goto error; } } @@ -5882,7 +5882,7 @@ virDomainMigrate2(virDomainPtr domain, ddomain = virDomainLookupByName(dconn, dname ? dname : domain->name); } else { /* This driver does not support peer to peer migration */ - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); goto error; } } else { @@ -5939,7 +5939,7 @@ virDomainMigrate2(virDomainPtr domain, dname, uri, bandwidth); } else { /* This driver does not support any migration method */ - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); goto error; } } @@ -6141,7 +6141,7 @@ virDomainMigrate3(virDomainPtr domain, dname, uri, bandwidth); } else { /* This driver does not support any migration method */ - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); goto error; } @@ -6280,7 +6280,7 @@ virDomainMigrateToURI(virDomainPtr domain, goto error; } else { /* No peer to peer migration supported */ - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); goto error; } } else { @@ -6435,7 +6435,7 @@ virDomainMigrateToURI2(virDomainPtr domain, goto error; } else { /* No peer to peer migration supported */ - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); goto error; } } else { @@ -6655,7 +6655,7 @@ virDomainMigratePrepare(virConnectPtr dconn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dconn); @@ -6706,7 +6706,7 @@ virDomainMigratePerform(virDomainPtr domain, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -6753,7 +6753,7 @@ virDomainMigrateFinish(virConnectPtr dconn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dconn); @@ -6805,7 +6805,7 @@ virDomainMigratePrepare2(virConnectPtr dconn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dconn); @@ -6854,7 +6854,7 @@ virDomainMigrateFinish2(virConnectPtr dconn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dconn); @@ -6907,7 +6907,7 @@ virDomainMigratePrepareTunnel(virConnectPtr conn, return rv; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -6960,7 +6960,7 @@ virDomainMigrateBegin3(virDomainPtr domain, return xml; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -7017,7 +7017,7 @@ virDomainMigratePrepare3(virConnectPtr dconn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dconn); @@ -7078,7 +7078,7 @@ virDomainMigratePrepareTunnel3(virConnectPtr conn, return rv; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -7138,7 +7138,7 @@ virDomainMigratePerform3(virDomainPtr domain, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -7192,7 +7192,7 @@ virDomainMigrateFinish3(virConnectPtr dconn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dconn); @@ -7241,7 +7241,7 @@ virDomainMigrateConfirm3(virDomainPtr domain, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -7293,7 +7293,7 @@ virDomainMigrateBegin3Params(virDomainPtr domain, return xml; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -7346,7 +7346,7 @@ virDomainMigratePrepare3Params(virConnectPtr dconn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dconn); @@ -7405,7 +7405,7 @@ virDomainMigratePrepareTunnel3Params(virConnectPtr conn, return rv; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -7460,7 +7460,7 @@ virDomainMigratePerform3Params(virDomainPtr domain, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -7512,7 +7512,7 @@ virDomainMigrateFinish3Params(virConnectPtr dconn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dconn); @@ -7564,7 +7564,7 @@ virDomainMigrateConfirm3Params(virDomainPtr domain, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -7603,7 +7603,7 @@ virNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -7643,7 +7643,7 @@ virConnectGetCapabilities(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -7738,7 +7738,7 @@ virNodeGetCPUStats(virConnectPtr conn, goto error; return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -7829,7 +7829,7 @@ virNodeGetMemoryStats(virConnectPtr conn, goto error; return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -7868,7 +7868,7 @@ virNodeGetFreeMemory(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -7928,7 +7928,7 @@ virNodeSuspendForDuration(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -7993,7 +7993,7 @@ virNodeGetMemoryParameters(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -8060,7 +8060,7 @@ virNodeSetMemoryParameters(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -8102,7 +8102,7 @@ virDomainGetSchedulerType(virDomainPtr domain, int *nparams) return schedtype; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -8160,7 +8160,7 @@ virDomainGetSchedulerParameters(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -8244,7 +8244,7 @@ virDomainGetSchedulerParametersFlags(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -8304,7 +8304,7 @@ virDomainSetSchedulerParameters(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -8372,7 +8372,7 @@ virDomainSetSchedulerParametersFlags(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -8440,7 +8440,7 @@ virDomainBlockStats(virDomainPtr dom, const char *disk, return 0; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -8522,7 +8522,7 @@ virDomainBlockStatsFlags(virDomainPtr dom, goto error; return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -8588,7 +8588,7 @@ virDomainInterfaceStats(virDomainPtr dom, const char *path, return 0; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -8656,7 +8656,7 @@ virDomainSetInterfaceParameters(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -8728,7 +8728,7 @@ virDomainGetInterfaceParameters(virDomainPtr domain, goto error; return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -8801,7 +8801,7 @@ virDomainMemoryStats(virDomainPtr dom, virDomainMemoryStatPtr stats, return nr_stats_ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -8895,7 +8895,7 @@ virDomainBlockPeek(virDomainPtr dom, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -8964,7 +8964,7 @@ virDomainBlockResize(virDomainPtr dom, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -9076,7 +9076,7 @@ virDomainMemoryPeek(virDomainPtr dom, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -9132,7 +9132,7 @@ virDomainGetBlockInfo(virDomainPtr domain, const char *disk, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -9189,7 +9189,7 @@ virDomainDefineXML(virConnectPtr conn, const char *xml) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -9240,7 +9240,7 @@ virDomainUndefine(virDomainPtr domain) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -9301,7 +9301,7 @@ virDomainUndefineFlags(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -9338,7 +9338,7 @@ virConnectNumOfDefinedDomains(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -9389,7 +9389,7 @@ virConnectListDefinedDomains(virConnectPtr conn, char **const names, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -9495,7 +9495,7 @@ virConnectListAllDomains(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -9542,7 +9542,7 @@ virDomainCreate(virDomainPtr domain) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -9611,7 +9611,7 @@ virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -9693,7 +9693,7 @@ virDomainCreateWithFiles(virDomainPtr domain, unsigned int nfiles, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -9739,7 +9739,7 @@ virDomainGetAutostart(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -9788,7 +9788,7 @@ virDomainSetAutostart(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -9833,7 +9833,7 @@ virDomainInjectNMI(virDomainPtr domain, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -9899,7 +9899,7 @@ virDomainSendKey(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -9978,7 +9978,7 @@ virDomainSendProcessSignal(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10034,7 +10034,7 @@ virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10123,7 +10123,7 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10193,7 +10193,7 @@ virDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10261,7 +10261,7 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10342,7 +10342,7 @@ virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10420,7 +10420,7 @@ virDomainGetVcpuPinInfo(virDomainPtr domain, int ncpumaps, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10495,7 +10495,7 @@ virDomainPinEmulator(virDomainPtr domain, unsigned char *cpumap, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10562,7 +10562,7 @@ virDomainGetEmulatorPinInfo(virDomainPtr domain, unsigned char *cpumap, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10639,7 +10639,7 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10684,7 +10684,7 @@ virDomainGetMaxVcpus(virDomainPtr domain) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10730,7 +10730,7 @@ virDomainGetSecurityLabel(virDomainPtr domain, virSecurityLabelPtr seclabel) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10778,7 +10778,7 @@ virDomainGetSecurityLabelList(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10875,7 +10875,7 @@ virDomainSetMetadata(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10954,7 +10954,7 @@ virDomainGetMetadata(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -10996,7 +10996,7 @@ virNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -11049,7 +11049,7 @@ virDomainAttachDevice(virDomainPtr domain, const char *xml) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -11113,7 +11113,7 @@ virDomainAttachDeviceFlags(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -11162,7 +11162,7 @@ virDomainDetachDevice(virDomainPtr domain, const char *xml) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -11242,7 +11242,7 @@ virDomainDetachDeviceFlags(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -11306,7 +11306,7 @@ virDomainUpdateDeviceFlags(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -11358,7 +11358,7 @@ virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -11458,7 +11458,7 @@ virConnectListAllNetworks(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -11495,7 +11495,7 @@ virConnectNumOfNetworks(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -11543,7 +11543,7 @@ virConnectListNetworks(virConnectPtr conn, char **const names, int maxnames) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -11580,7 +11580,7 @@ virConnectNumOfDefinedNetworks(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -11629,7 +11629,7 @@ virConnectListDefinedNetworks(virConnectPtr conn, char **const names, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -11669,7 +11669,7 @@ virNetworkLookupByName(virConnectPtr conn, const char *name) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -11710,7 +11710,7 @@ virNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -11796,7 +11796,7 @@ virNetworkCreateXML(virConnectPtr conn, const char *xmlDesc) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -11839,7 +11839,7 @@ virNetworkDefineXML(virConnectPtr conn, const char *xml) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -11882,7 +11882,7 @@ virNetworkUndefine(virNetworkPtr network) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(network->conn); @@ -11945,7 +11945,7 @@ virNetworkUpdate(virNetworkPtr network, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(network->conn); @@ -11989,7 +11989,7 @@ virNetworkCreate(virNetworkPtr network) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(network->conn); @@ -12036,7 +12036,7 @@ virNetworkDestroy(virNetworkPtr network) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(network->conn); @@ -12236,7 +12236,7 @@ virNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(network->conn); @@ -12278,7 +12278,7 @@ virNetworkGetBridgeName(virNetworkPtr network) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(network->conn); @@ -12323,7 +12323,7 @@ virNetworkGetAutostart(virNetworkPtr network, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(network->conn); @@ -12371,7 +12371,7 @@ virNetworkSetAutostart(virNetworkPtr network, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(network->conn); @@ -12463,7 +12463,7 @@ virConnectListAllInterfaces(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -12500,7 +12500,7 @@ virConnectNumOfInterfaces(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -12549,7 +12549,7 @@ virConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -12586,7 +12586,7 @@ virConnectNumOfDefinedInterfaces(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -12637,7 +12637,7 @@ virConnectListDefinedInterfaces(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -12677,7 +12677,7 @@ virInterfaceLookupByName(virConnectPtr conn, const char *name) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -12717,7 +12717,7 @@ virInterfaceLookupByMACString(virConnectPtr conn, const char *macstr) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -12819,7 +12819,7 @@ virInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(iface->conn); @@ -12873,7 +12873,7 @@ virInterfaceDefineXML(virConnectPtr conn, const char *xml, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -12927,7 +12927,7 @@ virInterfaceUndefine(virInterfacePtr iface) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(iface->conn); @@ -12976,7 +12976,7 @@ virInterfaceCreate(virInterfacePtr iface, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(iface->conn); @@ -13030,7 +13030,7 @@ virInterfaceDestroy(virInterfacePtr iface, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(iface->conn); @@ -13141,7 +13141,7 @@ virInterfaceChangeBegin(virConnectPtr conn, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13189,7 +13189,7 @@ virInterfaceChangeCommit(virConnectPtr conn, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13238,7 +13238,7 @@ virInterfaceChangeRollback(virConnectPtr conn, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13353,7 +13353,7 @@ virConnectListAllStoragePools(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13390,7 +13390,7 @@ virConnectNumOfStoragePools(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13442,7 +13442,7 @@ virConnectListStoragePools(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13479,7 +13479,7 @@ virConnectNumOfDefinedStoragePools(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13531,7 +13531,7 @@ virConnectListDefinedStoragePools(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13591,7 +13591,7 @@ virConnectFindStoragePoolSources(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13631,7 +13631,7 @@ virStoragePoolLookupByName(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13671,7 +13671,7 @@ virStoragePoolLookupByUUID(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13748,7 +13748,7 @@ virStoragePoolLookupByVolume(virStorageVolPtr vol) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(vol->conn); @@ -13797,7 +13797,7 @@ virStoragePoolCreateXML(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13844,7 +13844,7 @@ virStoragePoolDefineXML(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -13892,7 +13892,7 @@ virStoragePoolBuild(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -13935,7 +13935,7 @@ virStoragePoolUndefine(virStoragePoolPtr pool) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -13980,7 +13980,7 @@ virStoragePoolCreate(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14028,7 +14028,7 @@ virStoragePoolDestroy(virStoragePoolPtr pool) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14076,7 +14076,7 @@ virStoragePoolDelete(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14185,7 +14185,7 @@ virStoragePoolRefresh(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14322,7 +14322,7 @@ virStoragePoolGetInfo(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14366,7 +14366,7 @@ virStoragePoolGetXMLDesc(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14410,7 +14410,7 @@ virStoragePoolGetAutostart(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14457,7 +14457,7 @@ virStoragePoolSetAutostart(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14507,7 +14507,7 @@ virStoragePoolListAllVolumes(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14544,7 +14544,7 @@ virStoragePoolNumOfVolumes(virStoragePoolPtr pool) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14591,7 +14591,7 @@ virStoragePoolListVolumes(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14663,7 +14663,7 @@ virStorageVolLookupByName(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14705,7 +14705,7 @@ virStorageVolLookupByKey(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -14746,7 +14746,7 @@ virStorageVolLookupByPath(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -14852,7 +14852,7 @@ virStorageVolCreateXML(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14919,7 +14919,7 @@ virStorageVolCreateXMLFrom(virStoragePoolPtr pool, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); @@ -14988,7 +14988,7 @@ virStorageVolDownload(virStorageVolPtr vol, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(vol->conn); @@ -15059,7 +15059,7 @@ virStorageVolUpload(virStorageVolPtr vol, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(vol->conn); @@ -15105,7 +15105,7 @@ virStorageVolDelete(virStorageVolPtr vol, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(vol->conn); @@ -15152,7 +15152,7 @@ virStorageVolWipe(virStorageVolPtr vol, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(vol->conn); @@ -15202,7 +15202,7 @@ virStorageVolWipePattern(virStorageVolPtr vol, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(vol->conn); @@ -15308,7 +15308,7 @@ virStorageVolGetInfo(virStorageVolPtr vol, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(vol->conn); @@ -15351,7 +15351,7 @@ virStorageVolGetXMLDesc(virStorageVolPtr vol, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(vol->conn); @@ -15396,7 +15396,7 @@ virStorageVolGetPath(virStorageVolPtr vol) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(vol->conn); @@ -15478,7 +15478,7 @@ virStorageVolResize(virStorageVolPtr vol, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(vol->conn); @@ -15520,7 +15520,7 @@ virNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -15594,7 +15594,7 @@ virConnectListAllNodeDevices(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -15646,7 +15646,7 @@ virNodeListDevices(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -15686,7 +15686,7 @@ virNodeDeviceLookupByName(virConnectPtr conn, const char *name) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -15734,7 +15734,7 @@ virNodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -15772,7 +15772,7 @@ char *virNodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dev->conn); @@ -15829,7 +15829,7 @@ const char *virNodeDeviceGetParent(virNodeDevicePtr dev) if (dev->conn->nodeDeviceDriver && dev->conn->nodeDeviceDriver->nodeDeviceGetParent) { dev->parent = dev->conn->nodeDeviceDriver->nodeDeviceGetParent(dev); } else { - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); virDispatchError(dev->conn); return NULL; } @@ -15867,7 +15867,7 @@ virNodeDeviceNumOfCaps(virNodeDevicePtr dev) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dev->conn); @@ -15912,7 +15912,7 @@ virNodeDeviceListCaps(virNodeDevicePtr dev, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dev->conn); @@ -16030,7 +16030,7 @@ virNodeDeviceDettach(virNodeDevicePtr dev) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dev->conn); @@ -16095,7 +16095,7 @@ virNodeDeviceDetachFlags(virNodeDevicePtr dev, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dev->conn); @@ -16144,7 +16144,7 @@ virNodeDeviceReAttach(virNodeDevicePtr dev) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dev->conn); @@ -16195,7 +16195,7 @@ virNodeDeviceReset(virNodeDevicePtr dev) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dev->conn); @@ -16244,7 +16244,7 @@ virNodeDeviceCreateXML(virConnectPtr conn, return dev; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -16290,7 +16290,7 @@ virNodeDeviceDestroy(virNodeDevicePtr dev) return 0; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dev->conn); @@ -16349,7 +16349,7 @@ virConnectDomainEventRegister(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -16393,7 +16393,7 @@ virConnectDomainEventDeregister(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -16459,7 +16459,7 @@ virConnectNumOfSecrets(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -16527,7 +16527,7 @@ virConnectListAllSecrets(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -16569,7 +16569,7 @@ virConnectListSecrets(virConnectPtr conn, char **uuids, int maxuuids) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -16611,7 +16611,7 @@ virSecretLookupByUUID(virConnectPtr conn, const unsigned char *uuid) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -16698,7 +16698,7 @@ virSecretLookupByUsage(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -16748,7 +16748,7 @@ virSecretDefineXML(virConnectPtr conn, const char *xml, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -16919,7 +16919,7 @@ virSecretGetXMLDesc(virSecretPtr secret, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -16970,7 +16970,7 @@ virSecretSetValue(virSecretPtr secret, const unsigned char *value, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -17019,7 +17019,7 @@ virSecretGetValue(virSecretPtr secret, size_t *value_size, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -17065,7 +17065,7 @@ virSecretUndefine(virSecretPtr secret) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -17298,7 +17298,7 @@ virStreamSend(virStreamPtr stream, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(stream->conn); @@ -17396,7 +17396,7 @@ virStreamRecv(virStreamPtr stream, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(stream->conn); @@ -17643,7 +17643,7 @@ virStreamEventAddCallback(virStreamPtr stream, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(stream->conn); @@ -17686,7 +17686,7 @@ virStreamEventUpdateCallback(virStreamPtr stream, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(stream->conn); @@ -17724,7 +17724,7 @@ virStreamEventRemoveCallback(virStreamPtr stream) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(stream->conn); @@ -17769,7 +17769,7 @@ virStreamFinish(virStreamPtr stream) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(stream->conn); @@ -17816,7 +17816,7 @@ virStreamAbort(virStreamPtr stream) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(stream->conn); @@ -17886,7 +17886,7 @@ virDomainIsActive(virDomainPtr dom) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); return -1; @@ -17922,7 +17922,7 @@ virDomainIsPersistent(virDomainPtr dom) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); return -1; @@ -17957,7 +17957,7 @@ virDomainIsUpdated(virDomainPtr dom) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); return -1; @@ -17992,7 +17992,7 @@ virNetworkIsActive(virNetworkPtr net) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(net->conn); return -1; @@ -18028,7 +18028,7 @@ virNetworkIsPersistent(virNetworkPtr net) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(net->conn); return -1; @@ -18063,7 +18063,7 @@ virStoragePoolIsActive(virStoragePoolPtr pool) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); return -1; @@ -18099,7 +18099,7 @@ virStoragePoolIsPersistent(virStoragePoolPtr pool) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(pool->conn); return -1; @@ -18135,7 +18135,7 @@ virConnectNumOfNWFilters(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -18187,7 +18187,7 @@ virConnectListAllNWFilters(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -18229,7 +18229,7 @@ virConnectListNWFilters(virConnectPtr conn, char **const names, int maxnames) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -18269,7 +18269,7 @@ virNWFilterLookupByName(virConnectPtr conn, const char *name) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -18309,7 +18309,7 @@ virNWFilterLookupByUUID(virConnectPtr conn, const unsigned char *uuid) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -18512,7 +18512,7 @@ virNWFilterDefineXML(virConnectPtr conn, const char *xmlDesc) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -18558,7 +18558,7 @@ virNWFilterUndefine(virNWFilterPtr nwfilter) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(nwfilter->conn); @@ -18601,7 +18601,7 @@ virNWFilterGetXMLDesc(virNWFilterPtr nwfilter, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(nwfilter->conn); @@ -18672,7 +18672,7 @@ virInterfaceIsActive(virInterfacePtr iface) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(iface->conn); return -1; @@ -18707,7 +18707,7 @@ virConnectIsEncrypted(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -18746,7 +18746,7 @@ virConnectIsSecure(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -18788,7 +18788,7 @@ virConnectCompareCPU(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -18839,7 +18839,7 @@ virConnectGetCPUModelNames(virConnectPtr conn, const char *arch, char ***models, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -18898,7 +18898,7 @@ virConnectBaselineCPU(virConnectPtr conn, return cpu; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -18947,7 +18947,7 @@ virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -19007,7 +19007,7 @@ virDomainGetJobStats(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -19053,7 +19053,7 @@ virDomainAbortJob(virDomainPtr domain) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -19102,7 +19102,7 @@ virDomainMigrateSetMaxDowntime(virDomainPtr domain, return 0; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -19148,7 +19148,7 @@ virDomainMigrateGetCompressionCache(virDomainPtr domain, return 0; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -19199,7 +19199,7 @@ virDomainMigrateSetCompressionCache(virDomainPtr domain, return 0; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -19247,7 +19247,7 @@ virDomainMigrateSetMaxSpeed(virDomainPtr domain, return 0; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -19297,7 +19297,7 @@ virDomainMigrateGetMaxSpeed(virDomainPtr domain, return 0; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -19378,7 +19378,7 @@ virConnectDomainEventRegisterAny(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -19418,7 +19418,7 @@ virConnectDomainEventDeregisterAny(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -19503,7 +19503,7 @@ virConnectNetworkEventRegisterAny(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -19545,7 +19545,7 @@ virConnectNetworkEventDeregisterAny(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -19618,7 +19618,7 @@ virDomainManagedSave(virDomainPtr dom, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -19664,7 +19664,7 @@ virDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -19711,7 +19711,7 @@ virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -19958,7 +19958,7 @@ virDomainSnapshotCreateXML(virDomainPtr domain, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return NULL; @@ -20012,7 +20012,7 @@ virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return NULL; @@ -20083,7 +20083,7 @@ virDomainSnapshotNum(virDomainPtr domain, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -20175,7 +20175,7 @@ virDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -20261,7 +20261,7 @@ virDomainListAllSnapshots(virDomainPtr domain, virDomainSnapshotPtr **snaps, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -20333,7 +20333,7 @@ virDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -20431,7 +20431,7 @@ virDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -20520,7 +20520,7 @@ virDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -20568,7 +20568,7 @@ virDomainSnapshotLookupByName(virDomainPtr domain, return dom; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return NULL; @@ -20608,7 +20608,7 @@ virDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -20652,7 +20652,7 @@ virDomainSnapshotCurrent(virDomainPtr domain, return snap; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return NULL; @@ -20697,7 +20697,7 @@ virDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, return snap; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return NULL; @@ -20741,7 +20741,7 @@ virDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -20786,7 +20786,7 @@ virDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -20874,7 +20874,7 @@ virDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -20944,7 +20944,7 @@ virDomainSnapshotDelete(virDomainSnapshotPtr snapshot, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -21077,7 +21077,7 @@ virDomainOpenConsole(virDomainPtr dom, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -21140,7 +21140,7 @@ virDomainOpenChannel(virDomainPtr dom, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -21220,7 +21220,7 @@ virDomainBlockJobAbort(virDomainPtr dom, const char *disk, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -21277,7 +21277,7 @@ virDomainGetBlockJobInfo(virDomainPtr dom, const char *disk, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -21337,7 +21337,7 @@ virDomainBlockJobSetSpeed(virDomainPtr dom, const char *disk, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -21411,7 +21411,7 @@ virDomainBlockPull(virDomainPtr dom, const char *disk, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -21543,7 +21543,7 @@ virDomainBlockRebase(virDomainPtr dom, const char *disk, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -21651,7 +21651,7 @@ virDomainBlockCommit(virDomainPtr dom, const char *disk, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -21723,7 +21723,7 @@ virDomainOpenGraphics(virDomainPtr dom, if (!VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, VIR_DRV_FEATURE_FD_PASSING)) { - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); goto error; } @@ -21735,7 +21735,7 @@ virDomainOpenGraphics(virDomainPtr dom, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -21792,7 +21792,7 @@ virConnectSetKeepAlive(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -21831,7 +21831,7 @@ virConnectIsAlive(virConnectPtr conn) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); return -1; @@ -22029,7 +22029,7 @@ virDomainSetBlockIoTune(virDomainPtr dom, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -22119,7 +22119,7 @@ virDomainGetBlockIoTune(virDomainPtr dom, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -22266,7 +22266,7 @@ virDomainGetCPUStats(virDomainPtr domain, return ret; } - virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -22332,7 +22332,7 @@ virDomainGetDiskErrors(virDomainPtr dom, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); @@ -22378,7 +22378,7 @@ virDomainGetHostname(virDomainPtr domain, unsigned int flags) return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(domain->conn); @@ -22430,7 +22430,7 @@ virNodeGetCPUMap(virConnectPtr conn, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(conn); @@ -22487,7 +22487,7 @@ virDomainFSTrim(virDomainPtr dom, return ret; } - virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); error: virDispatchError(dom->conn); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 0fc5763..500470d 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2257,7 +2257,7 @@ lxcDomainInterfaceStats(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED, struct _virDomainInterfaceStats *stats ATTRIBUTE_UNUSED) { - virReportError(VIR_ERR_NO_SUPPORT, "%s", __FUNCTION__); + virReportUnsupportedError(); return -1; } #endif diff --git a/src/security/security_manager.c b/src/security/security_manager.c index 5b76ad8..db72e1b 100644 --- a/src/security/security_manager.c +++ b/src/security/security_manager.c @@ -256,7 +256,7 @@ virSecurityManagerGetDOI(virSecurityManagerPtr mgr) return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return NULL; } @@ -271,7 +271,7 @@ virSecurityManagerGetModel(virSecurityManagerPtr mgr) return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return NULL; } @@ -317,7 +317,7 @@ int virSecurityManagerRestoreImageLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -332,7 +332,7 @@ int virSecurityManagerSetDaemonSocketLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -347,7 +347,7 @@ int virSecurityManagerSetSocketLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -362,7 +362,7 @@ int virSecurityManagerClearSocketLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -378,7 +378,7 @@ int virSecurityManagerSetImageLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -395,7 +395,7 @@ int virSecurityManagerRestoreHostdevLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -412,7 +412,7 @@ int virSecurityManagerSetHostdevLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -428,7 +428,7 @@ int virSecurityManagerSetSavedStateLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -444,7 +444,7 @@ int virSecurityManagerRestoreSavedStateLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -512,7 +512,7 @@ int virSecurityManagerGenLabel(virSecurityManagerPtr mgr, } if (!sec_managers[i]->drv->domainGenSecurityLabel) { - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); } else { /* The seclabel must be added to @vm prior calling domainGenSecurityLabel * which may require seclabel to be presented already */ @@ -553,7 +553,7 @@ int virSecurityManagerReserveLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -568,7 +568,7 @@ int virSecurityManagerReleaseLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -584,7 +584,7 @@ int virSecurityManagerSetAllLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -600,7 +600,7 @@ int virSecurityManagerRestoreAllLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -617,7 +617,7 @@ int virSecurityManagerGetProcessLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -632,7 +632,7 @@ int virSecurityManagerSetProcessLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -643,7 +643,7 @@ int virSecurityManagerSetChildProcessLabel(virSecurityManagerPtr mgr, if (mgr->drv->domainSetSecurityChildProcessLabel) return mgr->drv->domainSetSecurityChildProcessLabel(mgr, vm, cmd); - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -671,7 +671,7 @@ int virSecurityManagerVerify(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -687,7 +687,7 @@ int virSecurityManagerSetImageFDLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -703,7 +703,7 @@ int virSecurityManagerSetTapFDLabel(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -718,7 +718,7 @@ char *virSecurityManagerGetMountOptions(virSecurityManagerPtr mgr, return ret; } - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); return NULL; } diff --git a/src/util/virerror.h b/src/util/virerror.h index 87272e9..ec7ef95 100644 --- a/src/util/virerror.h +++ b/src/util/virerror.h @@ -156,6 +156,11 @@ void virReportSystemErrorFull(int domcode, 0, 0, \ "%s", message); +# define virReportUnsupportedError() \ + virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_NO_SUPPORT, \ + __FILE__, __FUNCTION__, __LINE__, __FUNCTION__) + + void virReportOOMErrorFull(int domcode, const char *filename, const char *funcname, diff --git a/src/util/virinitctl.c b/src/util/virinitctl.c index 029dbb9..488deda 100644 --- a/src/util/virinitctl.c +++ b/src/util/virinitctl.c @@ -162,7 +162,7 @@ cleanup: int virInitctlSetRunLevel(virInitctlRunLevel level ATTRIBUTE_UNUSED, const char *vroot ATTRIBUTE_UNUSED) { - virReportError(VIR_ERR_NO_SUPPORT, "%s", __FUNCTION__); - return -1; + virReportUnsupportedError(); + return -1; } #endif diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 4103dc9..07f1ec0 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -2320,7 +2320,7 @@ xenUnifiedConnectDomainEventRegister(virConnectPtr conn, xenUnifiedLock(priv); if (priv->xsWatch == -1) { - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); xenUnifiedUnlock(priv); return -1; } @@ -2346,7 +2346,7 @@ xenUnifiedConnectDomainEventDeregister(virConnectPtr conn, xenUnifiedLock(priv); if (priv->xsWatch == -1) { - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); xenUnifiedUnlock(priv); return -1; } @@ -2377,7 +2377,7 @@ xenUnifiedConnectDomainEventRegisterAny(virConnectPtr conn, xenUnifiedLock(priv); if (priv->xsWatch == -1) { - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); xenUnifiedUnlock(priv); return -1; } @@ -2404,7 +2404,7 @@ xenUnifiedConnectDomainEventDeregisterAny(virConnectPtr conn, xenUnifiedLock(priv); if (priv->xsWatch == -1) { - virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + virReportUnsupportedError(); xenUnifiedUnlock(priv); return -1; } -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
We weren't very consistent in our use of VIR_ERR_NO_SUPPORT; many users just passed __FUNCTION__ on, while others passed "%s" to silence over-eager compilers that warn about __FUNCTION__ not containing any %. It's nicer to route all these uses through a single macro, so that if we ever need to change the reporting, we can do it in one place.
I verified that 'virsh -c test:///default qemu-monitor-command test foo' gives the same error message before and after this patch: error: this function is not supported by the connection driver: virDomainQemuMonitorCommand
Note that in libvirt.c, we were inconsistent on whether virDomain* API used virLibConnError() (with VIR_FROM_NONE) or virLibDomainError() (with VIR_FROM_DOMAIN); this patch unifies these errors to all use VIR_FROM_NONE, on the grounds that it is unlikely that a caller learning that a call is unimplemented can do anything in particular with extra knowledge of which error domain it belongs to.
* src/util/virerror.h (virReportUnsupportedError): New macro. * src/libvirt.c: Use it. * src/libvirt-qemu.c: Likewise. * src/libvirt-lxc.c: Likewise. * src/lxc/lxc_driver.c: Likewise. * src/security/security_manager.c: Likewise. * src/util/virinitctl.c: Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt-lxc.c | 2 +- src/libvirt-qemu.c | 7 +- src/libvirt.c | 612 ++++++++++++++++++++-------------------- src/lxc/lxc_driver.c | 2 +- src/security/security_manager.c | 46 +-- src/util/virerror.h | 5 + src/util/virinitctl.c | 4 +- src/xen/xen_driver.c | 8 +- 8 files changed, 345 insertions(+), 341 deletions(-)
Thus all error messages of this type will start with "libvirt: Unknown" rather than "some" starting with "libvirt: <domain-name>". I'm on the fence whether this is OK/desired. On one hand - it simplifies things and really API's aren't necessarily tied to domains. However, for applications that have a list of domains to try calling the same domain function that "has" been reporting the domain name upon return and checking if the domain is listed as not supporting a particular function, then this could cause a regression for them. Of course they'd have to have found one of the API's and they'd have to check the error message. Of course then there's the tester that creates a domain named "Unknown" that'll really be confused :-) The list of 23 API's in libvirt.c that would now use "Unknown" rather than the real name would be: virDomainMigratePerform Begin3 Perform3 Confirm3 Begin3Params Perform3Params Confirm3Params virDomainBlockStats InterfaceStats MemoryStats BlockPeek BlockResize MemoryPeek BlockJobAbort BlockJobInfo BlockJobSetSpeed BlockPull BlockRebase BlockCommit virDomainOpenGraphics <- Different than rest in the way it's checked SetBlockIoTune GetBlockIoTune GetCPUStats The only one that I'd say is different is virDomainOpenGraphics(). It checks VIR_DRV_SUPPORTS_FEATURE on one of its calls to virLibDomainError(). Thus perhaps it'd be better to generate a "real" error so as to differentiate between the function not being available as a general rule of thumb as opposed to it not being available to a specific domain because the domain doesn't support a specific feature. In this case VIR_DRV_FEATURE_FD_PASSING supported in the driver. I'm OK with an ACK - I just wanted to provide the "counter point" though to why a caller may want to know the domain name of an unimplemented function. Python makes it all too easy to snag error messages and make decisions based on "known" fields. John

On 01/02/2014 04:17 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
We weren't very consistent in our use of VIR_ERR_NO_SUPPORT; many users just passed __FUNCTION__ on, while others passed "%s" to silence over-eager compilers that warn about __FUNCTION__ not containing any %. It's nicer to route all these uses through a single macro, so that if we ever need to change the reporting, we can do it in one place.
I verified that 'virsh -c test:///default qemu-monitor-command test foo' gives the same error message before and after this patch: error: this function is not supported by the connection driver: virDomainQemuMonitorCommand
Note that in libvirt.c, we were inconsistent on whether virDomain* API used virLibConnError() (with VIR_FROM_NONE) or virLibDomainError() (with VIR_FROM_DOMAIN); this patch unifies these errors to all use VIR_FROM_NONE, on the grounds that it is unlikely that a caller learning that a call is unimplemented can do anything in particular with extra knowledge of which error domain it belongs to.
* src/util/virerror.h (virReportUnsupportedError): New macro. * src/libvirt.c: Use it. * src/libvirt-qemu.c: Likewise. * src/libvirt-lxc.c: Likewise. * src/lxc/lxc_driver.c: Likewise. * src/security/security_manager.c: Likewise. * src/util/virinitctl.c: Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt-lxc.c | 2 +- src/libvirt-qemu.c | 7 +- src/libvirt.c | 612 ++++++++++++++++++++-------------------- src/lxc/lxc_driver.c | 2 +- src/security/security_manager.c | 46 +-- src/util/virerror.h | 5 + src/util/virinitctl.c | 4 +- src/xen/xen_driver.c | 8 +- 8 files changed, 345 insertions(+), 341 deletions(-)
Thus all error messages of this type will start with "libvirt: Unknown" rather than "some" starting with "libvirt: <domain-name>".
hmm.. after re-reading virRaiseErrorFull(), virDefaultErrorFunc(), and friends - seems my eyes weren't functioning with my brain completely with regard to error domain and domain domain... I'm less concerned now with my original thoughts. Guess some of the work recently in virt-test has made me a bit more sensitive to changing error messages as believe it or not, they are used to make decisions in some tests to FAIL or SKIP based on whether some functionality exists. For example, if hotplug isn't supported an error is returned "cannot change vcpu count of this domain" - and that's a decision point for returning SKIP or FAIL. John
I'm on the fence whether this is OK/desired. On one hand - it simplifies things and really API's aren't necessarily tied to domains. However, for applications that have a list of domains to try calling the same domain function that "has" been reporting the domain name upon return and checking if the domain is listed as not supporting a particular function, then this could cause a regression for them. Of course they'd have to have found one of the API's and they'd have to check the error message. Of course then there's the tester that creates a domain named "Unknown" that'll really be confused :-)
The list of 23 API's in libvirt.c that would now use "Unknown" rather than the real name would be:
virDomainMigratePerform Begin3 Perform3 Confirm3 Begin3Params Perform3Params Confirm3Params virDomainBlockStats InterfaceStats MemoryStats BlockPeek BlockResize MemoryPeek BlockJobAbort BlockJobInfo BlockJobSetSpeed BlockPull BlockRebase BlockCommit virDomainOpenGraphics <- Different than rest in the way it's checked SetBlockIoTune GetBlockIoTune GetCPUStats
The only one that I'd say is different is virDomainOpenGraphics(). It checks VIR_DRV_SUPPORTS_FEATURE on one of its calls to virLibDomainError(). Thus perhaps it'd be better to generate a "real" error so as to differentiate between the function not being available as a general rule of thumb as opposed to it not being available to a specific domain because the domain doesn't support a specific feature. In this case VIR_DRV_FEATURE_FD_PASSING supported in the driver.
I'm OK with an ACK - I just wanted to provide the "counter point" though to why a caller may want to know the domain name of an unimplemented function. Python makes it all too easy to snag error messages and make decisions based on "known" fields.
John
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 01/02/2014 03:54 PM, John Ferlan wrote:
Note that in libvirt.c, we were inconsistent on whether virDomain* API used virLibConnError() (with VIR_FROM_NONE) or virLibDomainError() (with VIR_FROM_DOMAIN); this patch unifies these errors to all use VIR_FROM_NONE, on the grounds that it is unlikely that a caller learning that a call is unimplemented can do anything in particular with extra knowledge of which error domain it belongs to.
Thus all error messages of this type will start with "libvirt: Unknown" rather than "some" starting with "libvirt: <domain-name>".
Not quite. VIR_FROM_DOMAIN does not magically inject <domain-name> into the error message, it is only a meta-category that the end client can use to get an idea of where the error was issued (VIR_FROM_NONE in a generic file, VIR_FROM_DOMAIN in a file related mainly to common domain operations, VIR_FROM_QEMU in the qemu backend, and so forth). virsh uses this information in a couple of places, but it generally doesn't provide quite as much information as the actual error message (and the error message is unchanged).
hmm.. after re-reading virRaiseErrorFull(), virDefaultErrorFunc(), and friends - seems my eyes weren't functioning with my brain completely with regard to error domain and domain domain... I'm less concerned now with my original thoughts. Guess some of the work recently in virt-test has made me a bit more sensitive to changing error messages as believe it or not, they are used to make decisions in some tests to FAIL or SKIP based on whether some functionality exists. For example, if hotplug isn't supported an error is returned "cannot change vcpu count of this domain" - and that's a decision point for returning SKIP or FAIL.
Yep, glad to see that you figured this out in the meantime.
BlockCommit virDomainOpenGraphics <- Different than rest in the way it's checked SetBlockIoTune GetBlockIoTune GetCPUStats
The only one that I'd say is different is virDomainOpenGraphics(). It checks VIR_DRV_SUPPORTS_FEATURE on one of its calls to virLibDomainError(). Thus perhaps it'd be better to generate a "real" error so as to differentiate between the function not being available as a general rule of thumb as opposed to it not being available to a specific domain because the domain doesn't support a specific feature. In this case VIR_DRV_FEATURE_FD_PASSING supported in the driver.
Okay, I'll revisit that function, and possibly just defer that hunk or a modified version of it to my v2 series so I can push the rest of the patch.
I'm OK with an ACK - I just wanted to provide the "counter point" though to why a caller may want to know the domain name of an unimplemented function. Python makes it all too easy to snag error messages and make decisions based on "known" fields.
Again, it's not the domain name, but the category of which "type" of error is being issued, but knowing whether an unimplemented function is of type VIR_FROM_NONE or VIR_FROM_DOMAIN doesn't really help you use the function - either way, it still isn't implemented :) But I do appreciate the caution of making me justify why it is okay to make user-visible changes. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 01/04/2014 07:21 AM, Eric Blake wrote:
The only one that I'd say is different is virDomainOpenGraphics(). It checks VIR_DRV_SUPPORTS_FEATURE on one of its calls to virLibDomainError(). Thus perhaps it'd be better to generate a "real" error so as to differentiate between the function not being available as a general rule of thumb as opposed to it not being available to a specific domain because the domain doesn't support a specific feature. In this case VIR_DRV_FEATURE_FD_PASSING supported in the driver.
Okay, I'll revisit that function, and possibly just defer that hunk or a modified version of it to my v2 series so I can push the rest of the patch.
All other clients that report an error if VIR_DRV_SUPPORTS_FEATURE fails use VIR_ERR_ARGUMENT_UNSUPPORTED rather than VIR_ERR_NO_SUPPORT. So that seems straightforward enough that I squashed this in and pushed. diff --git i/src/libvirt.c w/src/libvirt.c index d9705bb..b0c1595 100644 --- i/src/libvirt.c +++ w/src/libvirt.c @@ -21759,7 +21759,8 @@ virDomainOpenGraphics(virDomainPtr dom, if (!VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, VIR_DRV_FEATURE_FD_PASSING)) { - virReportUnsupportedError(); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("fd passing is not supported by this connection")); goto error; } -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Some of our operation denied messages are outright stupid; for example, if virIdentitySetAttr fails: error: operation Identity attribute is already set forbidden for read only access This patch fixes things to a saner: error: operation forbidden: Identity attribute is already set It also consolidates the most common usage pattern for operation denied errors: read-only connections preventing a public API. In this case, 'virsh -r -c test:///default destroy test' changes from: error: operation virDomainDestroy forbidden for read only access to: error: operation forbidden: read only access prevents virDomainDestroy * src/util/virerror.c (virErrorMsg): Rework OPERATION_DENIED error message. * src/internal.h (virCheckReadOnlyGoto): New macro. * src/util/virerror.h (virReportRestrictedError): New macro. * src/libvirt-lxc.c: Use new macros. * src/libvirt-qemu.c: Likewise. * src/libvirt.c: Likewise. * src/locking/lock_daemon.c (virLockDaemonClientNew): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/internal.h | 9 + src/libvirt-lxc.c | 6 +- src/libvirt-qemu.c | 16 +- src/libvirt.c | 748 +++++++++------------------------------------- src/locking/lock_daemon.c | 16 +- src/util/virerror.c | 2 +- src/util/virerror.h | 3 + 7 files changed, 172 insertions(+), 628 deletions(-) diff --git a/src/internal.h b/src/internal.h index c90c83f..9b9bcc3 100644 --- a/src/internal.h +++ b/src/internal.h @@ -350,6 +350,15 @@ goto label; \ } \ } while (0) +# define virCheckReadOnlyGoto(flags, label) \ + do { \ + if ((flags) & VIR_CONNECT_RO) { \ + virReportRestrictedError(_("read only access prevents %s"), \ + __FUNCTION__); \ + goto label; \ + } \ + } while (0) + /* divide value by size, rounding up */ diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index 5bf5f56..fc56a58 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -83,11 +83,7 @@ virDomainLxcOpenNamespace(virDomainPtr domain, conn = domain->conn; virCheckNonNullArgGoto(fdlist, error); - - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainLxcOpenNamespace) { int ret; diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 79486fd..4aaff39 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -90,11 +90,7 @@ virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, conn = domain->conn; virCheckNonNullArgGoto(result, error); - - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainQemuMonitorCommand) { int ret; @@ -167,10 +163,7 @@ virDomainQemuAttach(virConnectPtr conn, goto error; } - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainQemuAttach) { virDomainPtr ret; @@ -229,10 +222,7 @@ virDomainQemuAgentCommand(virDomainPtr domain, conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(NULL, VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainQemuAgentCommand) { ret = conn->driver->domainQemuAgentCommand(domain, cmd, diff --git a/src/libvirt.c b/src/libvirt.c index 693adbf..6d1601f 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -2012,10 +2012,7 @@ virDomainCreateXML(virConnectPtr conn, const char *xmlDesc, return NULL; } virCheckNonNullArgGoto(xmlDesc, error); - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainCreateXML) { virDomainPtr ret; @@ -2084,10 +2081,7 @@ virDomainCreateXMLWithFiles(virConnectPtr conn, const char *xmlDesc, return NULL; } virCheckNonNullArgGoto(xmlDesc, error); - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainCreateXMLWithFiles) { virDomainPtr ret; @@ -2328,10 +2322,7 @@ virDomainDestroy(virDomainPtr domain) } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainDestroy) { int ret; @@ -2395,10 +2386,7 @@ virDomainDestroyFlags(virDomainPtr domain, } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainDestroyFlags) { int ret; @@ -2505,10 +2493,7 @@ virDomainSuspend(virDomainPtr domain) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; @@ -2554,10 +2539,7 @@ virDomainResume(virDomainPtr domain) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; @@ -2624,10 +2606,7 @@ virDomainPMSuspendForDuration(virDomainPtr dom, conn = dom->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainPMSuspendForDuration) { int ret; @@ -2676,10 +2655,7 @@ virDomainPMWakeup(virDomainPtr dom, conn = dom->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainPMWakeup) { int ret; @@ -2727,10 +2703,7 @@ virDomainSave(virDomainPtr domain, const char *to) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; virCheckNonNullArgGoto(to, error); @@ -2817,10 +2790,7 @@ virDomainSaveFlags(virDomainPtr domain, const char *to, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; virCheckNonNullArgGoto(to, error); @@ -2881,10 +2851,7 @@ virDomainRestore(virConnectPtr conn, const char *from) virDispatchError(NULL); return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(from, error); if (conn->driver->domainRestore) { @@ -2958,10 +2925,7 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml, virDispatchError(NULL); return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(from, error); if ((flags & VIR_DOMAIN_SAVE_RUNNING) && (flags & VIR_DOMAIN_SAVE_PAUSED)) { @@ -3108,10 +3072,7 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file, virDispatchError(NULL); return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(file, error); virCheckNonNullArgGoto(dxml, error); @@ -3189,10 +3150,7 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int flags) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; virCheckNonNullArgGoto(to, error); @@ -3284,11 +3242,7 @@ virDomainScreenshot(virDomainPtr domain, virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); return NULL; } - if (domain->conn->flags & VIR_CONNECT_RO || - stream->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags | stream->conn->flags, error); if (domain->conn->driver->domainScreenshot) { char * ret; @@ -3342,10 +3296,7 @@ virDomainShutdown(virDomainPtr domain) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; @@ -3406,10 +3357,7 @@ virDomainShutdownFlags(virDomainPtr domain, unsigned int flags) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; @@ -3471,10 +3419,7 @@ virDomainReboot(virDomainPtr domain, unsigned int flags) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; @@ -3522,10 +3467,7 @@ virDomainReset(virDomainPtr domain, unsigned int flags) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; @@ -3781,10 +3723,7 @@ virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonZeroArgGoto(memory, error); conn = domain->conn; @@ -3834,10 +3773,7 @@ virDomainSetMemory(virDomainPtr domain, unsigned long memory) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonZeroArgGoto(memory, error); conn = domain->conn; @@ -3899,10 +3835,7 @@ virDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonZeroArgGoto(memory, error); conn = domain->conn; @@ -3961,10 +3894,7 @@ virDomainSetMemoryStatsPeriod(virDomainPtr domain, int period, return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); /* This must be positive to set the balloon collection period */ virCheckNonNegativeArgGoto(period, error); @@ -4060,10 +3990,7 @@ virDomainSetMemoryParameters(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckPositiveArgGoto(nparams, error); @@ -4205,10 +4132,7 @@ virDomainSetNumaParameters(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckPositiveArgGoto(nparams, error); if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0) @@ -4334,10 +4258,7 @@ virDomainSetBlkioParameters(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error); @@ -4671,10 +4592,7 @@ char *virConnectDomainXMLFromNative(virConnectPtr conn, virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(nativeFormat, error); virCheckNonNullArgGoto(nativeConfig, error); @@ -4727,10 +4645,7 @@ char *virConnectDomainXMLToNative(virConnectPtr conn, virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(nativeFormat, error); virCheckNonNullArgGoto(domainXml, error); @@ -5582,21 +5497,14 @@ virDomainMigrate(virDomainPtr domain, virDispatchError(NULL); return NULL; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); /* Now checkout the destination */ if (!VIR_IS_CONNECT(dconn)) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); goto error; } - if (dconn->flags & VIR_CONNECT_RO) { - /* NB, deliberately report error against source object, not dest */ - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error); if (flags & VIR_MIGRATE_NON_SHARED_DISK && flags & VIR_MIGRATE_NON_SHARED_INC) { @@ -5822,21 +5730,14 @@ virDomainMigrate2(virDomainPtr domain, virDispatchError(NULL); return NULL; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); /* Now checkout the destination */ if (!VIR_IS_CONNECT(dconn)) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); goto error; } - if (dconn->flags & VIR_CONNECT_RO) { - /* NB, deliberately report error against source object, not dest */ - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error); if (flags & VIR_MIGRATE_NON_SHARED_DISK && flags & VIR_MIGRATE_NON_SHARED_INC) { @@ -6013,21 +5914,14 @@ virDomainMigrate3(virDomainPtr domain, virDispatchError(NULL); return NULL; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); /* Now checkout the destination */ if (!VIR_IS_CONNECT(dconn)) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); goto error; } - if (dconn->flags & VIR_CONNECT_RO) { - /* NB, deliberately report error against source object, not dest */ - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error); if (flags & VIR_MIGRATE_NON_SHARED_DISK && flags & VIR_MIGRATE_NON_SHARED_INC) { @@ -6246,10 +6140,7 @@ virDomainMigrateToURI(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(duri, error); @@ -6412,10 +6303,7 @@ virDomainMigrateToURI2(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); if (flags & VIR_MIGRATE_NON_SHARED_DISK && flags & VIR_MIGRATE_NON_SHARED_INC) { @@ -6528,10 +6416,7 @@ virDomainMigrateToURI3(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); if (flags & VIR_MIGRATE_NON_SHARED_DISK && flags & VIR_MIGRATE_NON_SHARED_INC) { @@ -6640,10 +6525,7 @@ virDomainMigratePrepare(virConnectPtr dconn, return -1; } - if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigratePrepare) { int ret; @@ -6691,10 +6573,7 @@ virDomainMigratePerform(virDomainPtr domain, } conn = domain->conn; - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); if (conn->driver->domainMigratePerform) { int ret; @@ -6738,10 +6617,7 @@ virDomainMigrateFinish(virConnectPtr dconn, return NULL; } - if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigrateFinish) { virDomainPtr ret; @@ -6789,10 +6665,7 @@ virDomainMigratePrepare2(virConnectPtr dconn, return -1; } - if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigratePrepare2) { int ret; @@ -6838,10 +6711,7 @@ virDomainMigrateFinish2(virConnectPtr dconn, return NULL; } - if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigrateFinish2) { virDomainPtr ret; @@ -6886,10 +6756,7 @@ virDomainMigratePrepareTunnel(virConnectPtr conn, return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn != st->conn) { virReportInvalidArg(conn, @@ -6944,10 +6811,7 @@ virDomainMigrateBegin3(virDomainPtr domain, } conn = domain->conn; - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); if (conn->driver->domainMigrateBegin3) { char *xml; @@ -6999,10 +6863,7 @@ virDomainMigratePrepare3(virConnectPtr dconn, return -1; } - if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigratePrepare3) { int ret; @@ -7055,10 +6916,7 @@ virDomainMigratePrepareTunnel3(virConnectPtr conn, return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn != st->conn) { virReportInvalidArg(conn, @@ -7121,10 +6979,7 @@ virDomainMigratePerform3(virDomainPtr domain, } conn = domain->conn; - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); if (conn->driver->domainMigratePerform3) { int ret; @@ -7175,10 +7030,7 @@ virDomainMigrateFinish3(virConnectPtr dconn, return NULL; } - if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigrateFinish3) { virDomainPtr ret; @@ -7226,10 +7078,7 @@ virDomainMigrateConfirm3(virDomainPtr domain, } conn = domain->conn; - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); if (conn->driver->domainMigrateConfirm3) { int ret; @@ -7277,10 +7126,7 @@ virDomainMigrateBegin3Params(virDomainPtr domain, } conn = domain->conn; - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); if (conn->driver->domainMigrateBegin3Params) { char *xml; @@ -7330,10 +7176,7 @@ virDomainMigratePrepare3Params(virConnectPtr dconn, return -1; } - if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigratePrepare3Params) { int ret; @@ -7383,10 +7226,7 @@ virDomainMigratePrepareTunnel3Params(virConnectPtr conn, return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn != st->conn) { virReportInvalidArg(conn, @@ -7445,10 +7285,7 @@ virDomainMigratePerform3Params(virDomainPtr domain, } conn = domain->conn; - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); if (conn->driver->domainMigratePerform3Params) { int ret; @@ -7497,10 +7334,7 @@ virDomainMigrateFinish3Params(virConnectPtr dconn, return NULL; } - if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigrateFinish3Params) { virDomainPtr ret; @@ -7549,10 +7383,7 @@ virDomainMigrateConfirm3Params(virDomainPtr domain, } conn = domain->conn; - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); if (conn->driver->domainMigrateConfirm3Params) { int ret; @@ -7914,10 +7745,7 @@ virNodeSuspendForDuration(virConnectPtr conn, return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->nodeSuspendForDuration) { int ret; @@ -8040,10 +7868,7 @@ virNodeSetMemoryParameters(virConnectPtr conn, return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error); @@ -8284,10 +8109,7 @@ virDomainSetSchedulerParameters(virDomainPtr domain, return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error); @@ -8349,10 +8171,7 @@ virDomainSetSchedulerParametersFlags(virDomainPtr domain, return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error); @@ -8634,10 +8453,7 @@ virDomainSetInterfaceParameters(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckPositiveArgGoto(nparams, error); @@ -8875,10 +8691,7 @@ virDomainBlockPeek(virDomainPtr dom, } conn = dom->conn; - if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error); virCheckNonNullArgGoto(disk, error); @@ -8949,10 +8762,7 @@ virDomainBlockResize(virDomainPtr dom, } conn = dom->conn; - if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error); virCheckNonNullArgGoto(disk, error); @@ -9027,10 +8837,7 @@ virDomainMemoryPeek(virDomainPtr dom, } conn = dom->conn; - if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error); /* Note on access to physical memory: A VIR_MEMORY_PHYSICAL flag is * a possibility. However it isn't really useful unless the caller @@ -9175,10 +8982,7 @@ virDomainDefineXML(virConnectPtr conn, const char *xml) virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); if (conn->driver->domainDefineXML) { @@ -9227,10 +9031,7 @@ virDomainUndefine(virDomainPtr domain) return -1; } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainUndefine) { int ret; @@ -9288,10 +9089,7 @@ virDomainUndefineFlags(virDomainPtr domain, return -1; } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainUndefineFlags) { int ret; @@ -9529,10 +9327,7 @@ virDomainCreate(virDomainPtr domain) return -1; } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainCreate) { int ret; @@ -9598,10 +9393,7 @@ virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) return -1; } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainCreateWithFlags) { int ret; @@ -9678,10 +9470,7 @@ virDomainCreateWithFiles(virDomainPtr domain, unsigned int nfiles, return -1; } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainCreateWithFiles) { int ret; @@ -9775,10 +9564,7 @@ virDomainSetAutostart(virDomainPtr domain, conn = domain->conn; - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); if (conn->driver->domainSetAutostart) { int ret; @@ -9818,10 +9604,7 @@ virDomainInjectNMI(virDomainPtr domain, unsigned int flags) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; @@ -9883,10 +9666,7 @@ virDomainSendKey(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; @@ -9960,10 +9740,7 @@ virDomainSendProcessSignal(virDomainPtr domain, virCheckNonZeroArgGoto(pid_value, error); - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; @@ -10017,10 +9794,7 @@ virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonZeroArgGoto(nvcpus, error); @@ -10093,10 +9867,7 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); if (flags & VIR_DOMAIN_VCPU_GUEST && flags & VIR_DOMAIN_VCPU_MAXIMUM) { @@ -10238,10 +10009,7 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(cpumap, error); virCheckPositiveArgGoto(maplen, error); @@ -10319,10 +10087,7 @@ virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu, return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(cpumap, error); virCheckPositiveArgGoto(maplen, error); @@ -10477,10 +10242,7 @@ virDomainPinEmulator(virDomainPtr domain, unsigned char *cpumap, return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(cpumap, error); virCheckPositiveArgGoto(maplen, error); @@ -10838,10 +10600,7 @@ virDomainSetMetadata(virDomainPtr domain, conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); switch (type) { case VIR_DOMAIN_METADATA_TITLE: @@ -11035,10 +10794,7 @@ virDomainAttachDevice(virDomainPtr domain, const char *xml) virCheckNonNullArgGoto(xml, error); - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; if (conn->driver->domainAttachDevice) { @@ -11099,10 +10855,7 @@ virDomainAttachDeviceFlags(virDomainPtr domain, virCheckNonNullArgGoto(xml, error); - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; if (conn->driver->domainAttachDeviceFlags) { @@ -11148,10 +10901,7 @@ virDomainDetachDevice(virDomainPtr domain, const char *xml) virCheckNonNullArgGoto(xml, error); - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; if (conn->driver->domainDetachDevice) { @@ -11228,10 +10978,7 @@ virDomainDetachDeviceFlags(virDomainPtr domain, virCheckNonNullArgGoto(xml, error); - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; if (conn->driver->domainDetachDeviceFlags) { @@ -11292,10 +11039,7 @@ virDomainUpdateDeviceFlags(virDomainPtr domain, virCheckNonNullArgGoto(xml, error); - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; if (conn->driver->domainUpdateDeviceFlags) { @@ -11783,10 +11527,7 @@ virNetworkCreateXML(virConnectPtr conn, const char *xmlDesc) } virCheckNonNullArgGoto(xmlDesc, error); - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->networkDriver && conn->networkDriver->networkCreateXML) { virNetworkPtr ret; @@ -11825,10 +11566,7 @@ virNetworkDefineXML(virConnectPtr conn, const char *xml) virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); if (conn->networkDriver && conn->networkDriver->networkDefineXML) { @@ -11869,10 +11607,7 @@ virNetworkUndefine(virNetworkPtr network) return -1; } conn = network->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibNetworkError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->networkDriver && conn->networkDriver->networkUndefine) { int ret; @@ -11929,10 +11664,7 @@ virNetworkUpdate(virNetworkPtr network, return -1; } conn = network->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibNetworkError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); @@ -11976,10 +11708,7 @@ virNetworkCreate(virNetworkPtr network) return -1; } conn = network->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibNetworkError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->networkDriver && conn->networkDriver->networkCreate) { int ret; @@ -12023,10 +11752,7 @@ virNetworkDestroy(virNetworkPtr network) } conn = network->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibNetworkError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->networkDriver && conn->networkDriver->networkDestroy) { int ret; @@ -12356,10 +12082,7 @@ virNetworkSetAutostart(virNetworkPtr network, return -1; } - if (network->conn->flags & VIR_CONNECT_RO) { - virLibNetworkError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(network->conn->flags, error); conn = network->conn; @@ -12859,10 +12582,7 @@ virInterfaceDefineXML(virConnectPtr conn, const char *xml, unsigned int flags) virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceDefineXML) { @@ -12914,10 +12634,7 @@ virInterfaceUndefine(virInterfacePtr iface) return -1; } conn = iface->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceUndefine) { int ret; @@ -12963,10 +12680,7 @@ virInterfaceCreate(virInterfacePtr iface, unsigned int flags) return -1; } conn = iface->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceCreate) { int ret; @@ -13017,10 +12731,7 @@ virInterfaceDestroy(virInterfacePtr iface, unsigned int flags) } conn = iface->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceDestroy) { int ret; @@ -13128,10 +12839,7 @@ virInterfaceChangeBegin(virConnectPtr conn, unsigned int flags) return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceChangeBegin) { int ret; @@ -13176,10 +12884,7 @@ virInterfaceChangeCommit(virConnectPtr conn, unsigned int flags) return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceChangeCommit) { int ret; @@ -13224,10 +12929,7 @@ virInterfaceChangeRollback(virConnectPtr conn, unsigned int flags) return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceChangeRollback) { @@ -13578,10 +13280,7 @@ virConnectFindStoragePoolSources(virConnectPtr conn, } virCheckNonNullArgGoto(type, error); - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->connectFindStoragePoolSources) { char *ret; @@ -13784,10 +13483,7 @@ virStoragePoolCreateXML(virConnectPtr conn, } virCheckNonNullArgGoto(xmlDesc, error); - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolCreateXML) { virStoragePoolPtr ret; @@ -13830,10 +13526,7 @@ virStoragePoolDefineXML(virConnectPtr conn, virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); if (conn->storageDriver && conn->storageDriver->storagePoolDefineXML) { @@ -13879,10 +13572,7 @@ virStoragePoolBuild(virStoragePoolPtr pool, return -1; } conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolBuild) { int ret; @@ -13922,10 +13612,7 @@ virStoragePoolUndefine(virStoragePoolPtr pool) return -1; } conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolUndefine) { int ret; @@ -13967,10 +13654,7 @@ virStoragePoolCreate(virStoragePoolPtr pool, return -1; } conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolCreate) { int ret; @@ -14015,10 +13699,7 @@ virStoragePoolDestroy(virStoragePoolPtr pool) } conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolDestroy) { int ret; @@ -14063,10 +13744,7 @@ virStoragePoolDelete(virStoragePoolPtr pool, } conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolDelete) { int ret; @@ -14172,10 +13850,7 @@ virStoragePoolRefresh(virStoragePoolPtr pool, } conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolRefresh) { int ret; @@ -14442,10 +14117,7 @@ virStoragePoolSetAutostart(virStoragePoolPtr pool, return -1; } - if (pool->conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(pool->conn->flags, error); conn = pool->conn; @@ -14839,10 +14511,7 @@ virStorageVolCreateXML(virStoragePoolPtr pool, virCheckNonNullArgGoto(xmlDesc, error); - if (pool->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(pool->conn->flags, error); if (pool->conn->storageDriver && pool->conn->storageDriver->storageVolCreateXML) { virStorageVolPtr ret; @@ -14902,12 +14571,7 @@ virStorageVolCreateXMLFrom(virStoragePoolPtr pool, } virCheckNonNullArgGoto(xmlDesc, error); - - if (pool->conn->flags & VIR_CONNECT_RO || - clonevol->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(pool->conn->flags | clonevol->conn->flags, error); if (pool->conn->storageDriver && pool->conn->storageDriver->storageVolCreateXMLFrom) { @@ -14969,11 +14633,7 @@ virStorageVolDownload(virStorageVolPtr vol, return -1; } - if (vol->conn->flags & VIR_CONNECT_RO || - stream->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(vol->conn->flags | stream->conn->flags, error); if (vol->conn->storageDriver && vol->conn->storageDriver->storageVolDownload) { @@ -15040,11 +14700,7 @@ virStorageVolUpload(virStorageVolPtr vol, return -1; } - if (vol->conn->flags & VIR_CONNECT_RO || - stream->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(vol->conn->flags | stream->conn->flags, error); if (vol->conn->storageDriver && vol->conn->storageDriver->storageVolUpload) { @@ -15092,10 +14748,7 @@ virStorageVolDelete(virStorageVolPtr vol, } conn = vol->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStorageVolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storageVolDelete) { int ret; @@ -15138,10 +14791,7 @@ virStorageVolWipe(virStorageVolPtr vol, } conn = vol->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStorageVolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storageVolWipe) { int ret; @@ -15188,10 +14838,7 @@ virStorageVolWipePattern(virStorageVolPtr vol, } conn = vol->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStorageVolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storageVolWipePattern) { int ret; @@ -15456,10 +15103,7 @@ virStorageVolResize(virStorageVolPtr vol, conn = vol->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); /* Zero capacity is only valid with either delta or shrink. */ if (capacity == 0 && !((flags & VIR_STORAGE_VOL_RESIZE_DELTA) || @@ -16017,10 +15661,7 @@ virNodeDeviceDettach(virNodeDevicePtr dev) return -1; } - if (dev->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dev->conn->flags, error); if (dev->conn->driver->nodeDeviceDettach) { int ret; @@ -16082,10 +15723,7 @@ virNodeDeviceDetachFlags(virNodeDevicePtr dev, return -1; } - if (dev->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dev->conn->flags, error); if (dev->conn->driver->nodeDeviceDetachFlags) { int ret; @@ -16131,10 +15769,7 @@ virNodeDeviceReAttach(virNodeDevicePtr dev) return -1; } - if (dev->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dev->conn->flags, error); if (dev->conn->driver->nodeDeviceReAttach) { int ret; @@ -16182,10 +15817,7 @@ virNodeDeviceReset(virNodeDevicePtr dev) return -1; } - if (dev->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dev->conn->flags, error); if (dev->conn->driver->nodeDeviceReset) { int ret; @@ -16229,10 +15861,7 @@ virNodeDeviceCreateXML(virConnectPtr conn, return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xmlDesc, error); @@ -16275,10 +15904,7 @@ virNodeDeviceDestroy(virNodeDevicePtr dev) return -1; } - if (dev->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dev->conn->flags, error); if (dev->conn->nodeDeviceDriver && dev->conn->nodeDeviceDriver->nodeDeviceDestroy) { @@ -16733,10 +16359,7 @@ virSecretDefineXML(virConnectPtr conn, const char *xml, unsigned int flags) virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); if (conn->secretDriver != NULL && conn->secretDriver->secretDefineXML != NULL) { @@ -16955,10 +16578,7 @@ virSecretSetValue(virSecretPtr secret, const unsigned char *value, return -1; } conn = secret->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibSecretError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(value, error); if (conn->secretDriver != NULL && conn->secretDriver->secretSetValue != NULL) { @@ -17004,10 +16624,7 @@ virSecretGetValue(virSecretPtr secret, size_t *value_size, unsigned int flags) return NULL; } conn = secret->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibSecretError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(value_size, error); if (conn->secretDriver != NULL && conn->secretDriver->secretGetValue != NULL) { @@ -17051,10 +16668,7 @@ virSecretUndefine(virSecretPtr secret) return -1; } conn = secret->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibSecretError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->secretDriver != NULL && conn->secretDriver->secretUndefine != NULL) { int ret; @@ -18499,10 +18113,7 @@ virNWFilterDefineXML(virConnectPtr conn, const char *xmlDesc) } virCheckNonNullArgGoto(xmlDesc, error); - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterDefineXML) { virNWFilterPtr ret; @@ -18545,10 +18156,7 @@ virNWFilterUndefine(virNWFilterPtr nwfilter) } conn = nwfilter->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibNWFilterError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterUndefine) { int ret; @@ -19040,10 +18648,7 @@ virDomainAbortJob(virDomainPtr domain) } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainAbortJob) { int ret; @@ -19091,10 +18696,7 @@ virDomainMigrateSetMaxDowntime(virDomainPtr domain, } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateSetMaxDowntime) { if (conn->driver->domainMigrateSetMaxDowntime(domain, downtime, flags) < 0) @@ -19187,10 +18789,7 @@ virDomainMigrateSetCompressionCache(virDomainPtr domain, } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateSetCompressionCache) { if (conn->driver->domainMigrateSetCompressionCache(domain, cacheSize, @@ -19236,10 +18835,7 @@ virDomainMigrateSetMaxSpeed(virDomainPtr domain, } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateSetMaxSpeed) { if (conn->driver->domainMigrateSetMaxSpeed(domain, bandwidth, flags) < 0) @@ -19286,10 +18882,7 @@ virDomainMigrateGetMaxSpeed(virDomainPtr domain, virCheckNonNullArgGoto(bandwidth, error); - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateGetMaxSpeed) { if (conn->driver->domainMigrateGetMaxSpeed(domain, bandwidth, flags) < 0) @@ -19597,10 +19190,7 @@ virDomainManagedSave(virDomainPtr dom, unsigned int flags) } conn = dom->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if ((flags & VIR_DOMAIN_SAVE_RUNNING) && (flags & VIR_DOMAIN_SAVE_PAUSED)) { virReportInvalidArg(flags, @@ -19697,10 +19287,7 @@ virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) } conn = dom->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainManagedSaveRemove) { int ret; @@ -19923,10 +19510,7 @@ virDomainSnapshotCreateXML(virDomainPtr domain, virCheckNonNullArgGoto(xmlDesc, error); - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT) && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE)) { @@ -20854,10 +20438,7 @@ virDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, } conn = snapshot->domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if ((flags & VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING) && (flags & VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) { @@ -20923,10 +20504,7 @@ virDomainSnapshotDelete(virDomainSnapshotPtr snapshot, } conn = snapshot->domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if ((flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) && (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { @@ -21064,10 +20642,7 @@ virDomainOpenConsole(virDomainPtr dom, } conn = dom->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainOpenConsole) { int ret; @@ -21127,10 +20702,7 @@ virDomainOpenChannel(virDomainPtr dom, } conn = dom->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainOpenChannel) { int ret; @@ -21205,10 +20777,7 @@ virDomainBlockJobAbort(virDomainPtr dom, const char *disk, } conn = dom->conn; - if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error); virCheckNonNullArgGoto(disk, error); @@ -21322,10 +20891,7 @@ virDomainBlockJobSetSpeed(virDomainPtr dom, const char *disk, } conn = dom->conn; - if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error); virCheckNonNullArgGoto(disk, error); @@ -21396,10 +20962,7 @@ virDomainBlockPull(virDomainPtr dom, const char *disk, } conn = dom->conn; - if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error); virCheckNonNullArgGoto(disk, error); @@ -21516,10 +21079,7 @@ virDomainBlockRebase(virDomainPtr dom, const char *disk, } conn = dom->conn; - if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error); virCheckNonNullArgGoto(disk, error); @@ -21635,10 +21195,7 @@ virDomainBlockCommit(virDomainPtr dom, const char *disk, } conn = dom->conn; - if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error); virCheckNonNullArgGoto(disk, error); @@ -21716,10 +21273,7 @@ virDomainOpenGraphics(virDomainPtr dom, goto error; } - if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error); if (!VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, VIR_DRV_FEATURE_FD_PASSING)) { @@ -22007,10 +21561,7 @@ virDomainSetBlockIoTune(virDomainPtr dom, return -1; } - if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error); virCheckNonNullArgGoto(disk, error); virCheckPositiveArgGoto(nparams, error); @@ -22474,10 +22025,7 @@ virDomainFSTrim(virDomainPtr dom, return -1; } - if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error); if (dom->conn->driver->domainFSTrim) { int ret = dom->conn->driver->domainFSTrim(dom, mountPoint, diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index a6be43c..b4ed14b 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -1,7 +1,7 @@ /* * lock_daemon.c: lock management daemon * - * Copyright (C) 2006-2012 Red Hat, Inc. + * Copyright (C) 2006-2013 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -800,18 +800,16 @@ virLockDaemonClientNew(virNetServerClientPtr client, if (!privileged) { if (geteuid() != clientuid) { - virReportError(VIR_ERR_OPERATION_DENIED, - _("Disallowing client %llu with uid %llu"), - (unsigned long long)priv->clientPid, - (unsigned long long)clientuid); + virReportRestrictedError(_("Disallowing client %llu with uid %llu"), + (unsigned long long)priv->clientPid, + (unsigned long long)clientuid); goto error; } } else { if (clientuid != 0) { - virReportError(VIR_ERR_OPERATION_DENIED, - _("Disallowing client %llu with uid %llu"), - (unsigned long long)priv->clientPid, - (unsigned long long)clientuid); + virReportRestrictedError(_("Disallowing client %llu with uid %llu"), + (unsigned long long)priv->clientPid, + (unsigned long long)clientuid); goto error; } } diff --git a/src/util/virerror.c b/src/util/virerror.c index d9a9fc4..877c15e 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -888,7 +888,7 @@ virErrorMsg(virErrorNumber error, const char *info) if (info == NULL) errmsg = _("operation forbidden for read only access"); else - errmsg = _("operation %s forbidden for read only access"); + errmsg = _("operation forbidden: %s"); break; case VIR_ERR_OPEN_FAILED: if (info == NULL) diff --git a/src/util/virerror.h b/src/util/virerror.h index ec7ef95..65c134c 100644 --- a/src/util/virerror.h +++ b/src/util/virerror.h @@ -159,6 +159,9 @@ void virReportSystemErrorFull(int domcode, # define virReportUnsupportedError() \ virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_NO_SUPPORT, \ __FILE__, __FUNCTION__, __LINE__, __FUNCTION__) +# define virReportRestrictedError(...) \ + virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_OPERATION_DENIED, \ + __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) void virReportOOMErrorFull(int domcode, -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
Some of our operation denied messages are outright stupid; for example, if virIdentitySetAttr fails:
error: operation Identity attribute is already set forbidden for read only access
This patch fixes things to a saner:
error: operation forbidden: Identity attribute is already set
It also consolidates the most common usage pattern for operation denied errors: read-only connections preventing a public API. In this case, 'virsh -r -c test:///default destroy test' changes from:
error: operation virDomainDestroy forbidden for read only access
to:
error: operation forbidden: read only access prevents virDomainDestroy
* src/util/virerror.c (virErrorMsg): Rework OPERATION_DENIED error message. * src/internal.h (virCheckReadOnlyGoto): New macro. * src/util/virerror.h (virReportRestrictedError): New macro. * src/libvirt-lxc.c: Use new macros. * src/libvirt-qemu.c: Likewise. * src/libvirt.c: Likewise. * src/locking/lock_daemon.c (virLockDaemonClientNew): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/internal.h | 9 + src/libvirt-lxc.c | 6 +- src/libvirt-qemu.c | 16 +- src/libvirt.c | 748 +++++++++------------------------------------- src/locking/lock_daemon.c | 16 +- src/util/virerror.c | 2 +- src/util/virerror.h | 3 + 7 files changed, 172 insertions(+), 628 deletions(-)
Yet another case where in libvirt.c the error changes from VIR_FROM_xxxx to VIR_FROM_NONE (_THIS technically). Where xxxx is DOM, INTERFACE, STORAGE, etc. Not that it should matter, but it I figured it should be pointed out. Perhaps more so in this case, the failure is related directly to the connection rather than function... ACK - for what's there. John
diff --git a/src/internal.h b/src/internal.h index c90c83f..9b9bcc3 100644 --- a/src/internal.h +++ b/src/internal.h @@ -350,6 +350,15 @@ goto label; \ } \ } while (0) +# define virCheckReadOnlyGoto(flags, label) \ + do { \ + if ((flags) & VIR_CONNECT_RO) { \ + virReportRestrictedError(_("read only access prevents %s"), \ + __FUNCTION__); \ + goto label; \ + } \ + } while (0) +
/* divide value by size, rounding up */ diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index 5bf5f56..fc56a58 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -83,11 +83,7 @@ virDomainLxcOpenNamespace(virDomainPtr domain, conn = domain->conn;
virCheckNonNullArgGoto(fdlist, error); - - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainLxcOpenNamespace) { int ret; diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 79486fd..4aaff39 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -90,11 +90,7 @@ virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, conn = domain->conn;
virCheckNonNullArgGoto(result, error); - - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainQemuMonitorCommand) { int ret; @@ -167,10 +163,7 @@ virDomainQemuAttach(virConnectPtr conn, goto error; }
- if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainQemuAttach) { virDomainPtr ret; @@ -229,10 +222,7 @@ virDomainQemuAgentCommand(virDomainPtr domain,
conn = domain->conn;
- if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(NULL, VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainQemuAgentCommand) { ret = conn->driver->domainQemuAgentCommand(domain, cmd, diff --git a/src/libvirt.c b/src/libvirt.c index 693adbf..6d1601f 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -2012,10 +2012,7 @@ virDomainCreateXML(virConnectPtr conn, const char *xmlDesc, return NULL; } virCheckNonNullArgGoto(xmlDesc, error); - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainCreateXML) { virDomainPtr ret; @@ -2084,10 +2081,7 @@ virDomainCreateXMLWithFiles(virConnectPtr conn, const char *xmlDesc, return NULL; } virCheckNonNullArgGoto(xmlDesc, error); - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainCreateXMLWithFiles) { virDomainPtr ret; @@ -2328,10 +2322,7 @@ virDomainDestroy(virDomainPtr domain) }
conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainDestroy) { int ret; @@ -2395,10 +2386,7 @@ virDomainDestroyFlags(virDomainPtr domain, }
conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainDestroyFlags) { int ret; @@ -2505,10 +2493,7 @@ virDomainSuspend(virDomainPtr domain) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
conn = domain->conn;
@@ -2554,10 +2539,7 @@ virDomainResume(virDomainPtr domain) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
conn = domain->conn;
@@ -2624,10 +2606,7 @@ virDomainPMSuspendForDuration(virDomainPtr dom,
conn = dom->conn;
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainPMSuspendForDuration) { int ret; @@ -2676,10 +2655,7 @@ virDomainPMWakeup(virDomainPtr dom,
conn = dom->conn;
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainPMWakeup) { int ret; @@ -2727,10 +2703,7 @@ virDomainSave(virDomainPtr domain, const char *to) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; virCheckNonNullArgGoto(to, error);
@@ -2817,10 +2790,7 @@ virDomainSaveFlags(virDomainPtr domain, const char *to, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; virCheckNonNullArgGoto(to, error);
@@ -2881,10 +2851,7 @@ virDomainRestore(virConnectPtr conn, const char *from) virDispatchError(NULL); return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(from, error);
if (conn->driver->domainRestore) { @@ -2958,10 +2925,7 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml, virDispatchError(NULL); return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(from, error);
if ((flags & VIR_DOMAIN_SAVE_RUNNING) && (flags & VIR_DOMAIN_SAVE_PAUSED)) { @@ -3108,10 +3072,7 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file, virDispatchError(NULL); return -1; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(file, error); virCheckNonNullArgGoto(dxml, error);
@@ -3189,10 +3150,7 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int flags) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn; virCheckNonNullArgGoto(to, error);
@@ -3284,11 +3242,7 @@ virDomainScreenshot(virDomainPtr domain, virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); return NULL; } - if (domain->conn->flags & VIR_CONNECT_RO || - stream->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags | stream->conn->flags, error);
if (domain->conn->driver->domainScreenshot) { char * ret; @@ -3342,10 +3296,7 @@ virDomainShutdown(virDomainPtr domain) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
conn = domain->conn;
@@ -3406,10 +3357,7 @@ virDomainShutdownFlags(virDomainPtr domain, unsigned int flags) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
conn = domain->conn;
@@ -3471,10 +3419,7 @@ virDomainReboot(virDomainPtr domain, unsigned int flags) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
conn = domain->conn;
@@ -3522,10 +3467,7 @@ virDomainReset(virDomainPtr domain, unsigned int flags) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
conn = domain->conn;
@@ -3781,10 +3723,7 @@ virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonZeroArgGoto(memory, error);
conn = domain->conn; @@ -3834,10 +3773,7 @@ virDomainSetMemory(virDomainPtr domain, unsigned long memory) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonZeroArgGoto(memory, error);
conn = domain->conn; @@ -3899,10 +3835,7 @@ virDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, return -1; }
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonZeroArgGoto(memory, error);
conn = domain->conn; @@ -3961,10 +3894,7 @@ virDomainSetMemoryStatsPeriod(virDomainPtr domain, int period, return -1; }
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
/* This must be positive to set the balloon collection period */ virCheckNonNegativeArgGoto(period, error); @@ -4060,10 +3990,7 @@ virDomainSetMemoryParameters(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckPositiveArgGoto(nparams, error);
@@ -4205,10 +4132,7 @@ virDomainSetNumaParameters(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckPositiveArgGoto(nparams, error); if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0) @@ -4334,10 +4258,7 @@ virDomainSetBlkioParameters(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error);
@@ -4671,10 +4592,7 @@ char *virConnectDomainXMLFromNative(virConnectPtr conn, virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
virCheckNonNullArgGoto(nativeFormat, error); virCheckNonNullArgGoto(nativeConfig, error); @@ -4727,10 +4645,7 @@ char *virConnectDomainXMLToNative(virConnectPtr conn, virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
virCheckNonNullArgGoto(nativeFormat, error); virCheckNonNullArgGoto(domainXml, error); @@ -5582,21 +5497,14 @@ virDomainMigrate(virDomainPtr domain, virDispatchError(NULL); return NULL; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
/* Now checkout the destination */ if (!VIR_IS_CONNECT(dconn)) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); goto error; } - if (dconn->flags & VIR_CONNECT_RO) { - /* NB, deliberately report error against source object, not dest */ - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error);
if (flags & VIR_MIGRATE_NON_SHARED_DISK && flags & VIR_MIGRATE_NON_SHARED_INC) { @@ -5822,21 +5730,14 @@ virDomainMigrate2(virDomainPtr domain, virDispatchError(NULL); return NULL; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
/* Now checkout the destination */ if (!VIR_IS_CONNECT(dconn)) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); goto error; } - if (dconn->flags & VIR_CONNECT_RO) { - /* NB, deliberately report error against source object, not dest */ - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error);
if (flags & VIR_MIGRATE_NON_SHARED_DISK && flags & VIR_MIGRATE_NON_SHARED_INC) { @@ -6013,21 +5914,14 @@ virDomainMigrate3(virDomainPtr domain, virDispatchError(NULL); return NULL; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
/* Now checkout the destination */ if (!VIR_IS_CONNECT(dconn)) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); goto error; } - if (dconn->flags & VIR_CONNECT_RO) { - /* NB, deliberately report error against source object, not dest */ - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error);
if (flags & VIR_MIGRATE_NON_SHARED_DISK && flags & VIR_MIGRATE_NON_SHARED_INC) { @@ -6246,10 +6140,7 @@ virDomainMigrateToURI(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
virCheckNonNullArgGoto(duri, error);
@@ -6412,10 +6303,7 @@ virDomainMigrateToURI2(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
if (flags & VIR_MIGRATE_NON_SHARED_DISK && flags & VIR_MIGRATE_NON_SHARED_INC) { @@ -6528,10 +6416,7 @@ virDomainMigrateToURI3(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
if (flags & VIR_MIGRATE_NON_SHARED_DISK && flags & VIR_MIGRATE_NON_SHARED_INC) { @@ -6640,10 +6525,7 @@ virDomainMigratePrepare(virConnectPtr dconn, return -1; }
- if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error);
if (dconn->driver->domainMigratePrepare) { int ret; @@ -6691,10 +6573,7 @@ virDomainMigratePerform(virDomainPtr domain, } conn = domain->conn;
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
if (conn->driver->domainMigratePerform) { int ret; @@ -6738,10 +6617,7 @@ virDomainMigrateFinish(virConnectPtr dconn, return NULL; }
- if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error);
if (dconn->driver->domainMigrateFinish) { virDomainPtr ret; @@ -6789,10 +6665,7 @@ virDomainMigratePrepare2(virConnectPtr dconn, return -1; }
- if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error);
if (dconn->driver->domainMigratePrepare2) { int ret; @@ -6838,10 +6711,7 @@ virDomainMigrateFinish2(virConnectPtr dconn, return NULL; }
- if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error);
if (dconn->driver->domainMigrateFinish2) { virDomainPtr ret; @@ -6886,10 +6756,7 @@ virDomainMigratePrepareTunnel(virConnectPtr conn, return -1; }
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn != st->conn) { virReportInvalidArg(conn, @@ -6944,10 +6811,7 @@ virDomainMigrateBegin3(virDomainPtr domain, } conn = domain->conn;
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
if (conn->driver->domainMigrateBegin3) { char *xml; @@ -6999,10 +6863,7 @@ virDomainMigratePrepare3(virConnectPtr dconn, return -1; }
- if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error);
if (dconn->driver->domainMigratePrepare3) { int ret; @@ -7055,10 +6916,7 @@ virDomainMigratePrepareTunnel3(virConnectPtr conn, return -1; }
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn != st->conn) { virReportInvalidArg(conn, @@ -7121,10 +6979,7 @@ virDomainMigratePerform3(virDomainPtr domain, } conn = domain->conn;
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
if (conn->driver->domainMigratePerform3) { int ret; @@ -7175,10 +7030,7 @@ virDomainMigrateFinish3(virConnectPtr dconn, return NULL; }
- if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error);
if (dconn->driver->domainMigrateFinish3) { virDomainPtr ret; @@ -7226,10 +7078,7 @@ virDomainMigrateConfirm3(virDomainPtr domain, } conn = domain->conn;
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
if (conn->driver->domainMigrateConfirm3) { int ret; @@ -7277,10 +7126,7 @@ virDomainMigrateBegin3Params(virDomainPtr domain, } conn = domain->conn;
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
if (conn->driver->domainMigrateBegin3Params) { char *xml; @@ -7330,10 +7176,7 @@ virDomainMigratePrepare3Params(virConnectPtr dconn, return -1; }
- if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error);
if (dconn->driver->domainMigratePrepare3Params) { int ret; @@ -7383,10 +7226,7 @@ virDomainMigratePrepareTunnel3Params(virConnectPtr conn, return -1; }
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn != st->conn) { virReportInvalidArg(conn, @@ -7445,10 +7285,7 @@ virDomainMigratePerform3Params(virDomainPtr domain, } conn = domain->conn;
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
if (conn->driver->domainMigratePerform3Params) { int ret; @@ -7497,10 +7334,7 @@ virDomainMigrateFinish3Params(virConnectPtr dconn, return NULL; }
- if (dconn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dconn->flags, error);
if (dconn->driver->domainMigrateFinish3Params) { virDomainPtr ret; @@ -7549,10 +7383,7 @@ virDomainMigrateConfirm3Params(virDomainPtr domain, } conn = domain->conn;
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
if (conn->driver->domainMigrateConfirm3Params) { int ret; @@ -7914,10 +7745,7 @@ virNodeSuspendForDuration(virConnectPtr conn, return -1; }
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->nodeSuspendForDuration) { int ret; @@ -8040,10 +7868,7 @@ virNodeSetMemoryParameters(virConnectPtr conn, return -1; }
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error); @@ -8284,10 +8109,7 @@ virDomainSetSchedulerParameters(virDomainPtr domain, return -1; }
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error);
@@ -8349,10 +8171,7 @@ virDomainSetSchedulerParametersFlags(virDomainPtr domain, return -1; }
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error);
@@ -8634,10 +8453,7 @@ virDomainSetInterfaceParameters(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckPositiveArgGoto(nparams, error);
@@ -8875,10 +8691,7 @@ virDomainBlockPeek(virDomainPtr dom, } conn = dom->conn;
- if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error);
virCheckNonNullArgGoto(disk, error);
@@ -8949,10 +8762,7 @@ virDomainBlockResize(virDomainPtr dom, } conn = dom->conn;
- if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error);
virCheckNonNullArgGoto(disk, error);
@@ -9027,10 +8837,7 @@ virDomainMemoryPeek(virDomainPtr dom, } conn = dom->conn;
- if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error);
/* Note on access to physical memory: A VIR_MEMORY_PHYSICAL flag is * a possibility. However it isn't really useful unless the caller @@ -9175,10 +8982,7 @@ virDomainDefineXML(virConnectPtr conn, const char *xml) virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error);
if (conn->driver->domainDefineXML) { @@ -9227,10 +9031,7 @@ virDomainUndefine(virDomainPtr domain) return -1; } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainUndefine) { int ret; @@ -9288,10 +9089,7 @@ virDomainUndefineFlags(virDomainPtr domain, return -1; } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainUndefineFlags) { int ret; @@ -9529,10 +9327,7 @@ virDomainCreate(virDomainPtr domain) return -1; } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainCreate) { int ret; @@ -9598,10 +9393,7 @@ virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) return -1; } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainCreateWithFlags) { int ret; @@ -9678,10 +9470,7 @@ virDomainCreateWithFiles(virDomainPtr domain, unsigned int nfiles, return -1; } conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainCreateWithFiles) { int ret; @@ -9775,10 +9564,7 @@ virDomainSetAutostart(virDomainPtr domain,
conn = domain->conn;
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
if (conn->driver->domainSetAutostart) { int ret; @@ -9818,10 +9604,7 @@ virDomainInjectNMI(virDomainPtr domain, unsigned int flags) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
conn = domain->conn;
@@ -9883,10 +9666,7 @@ virDomainSendKey(virDomainPtr domain, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
conn = domain->conn;
@@ -9960,10 +9740,7 @@ virDomainSendProcessSignal(virDomainPtr domain,
virCheckNonZeroArgGoto(pid_value, error);
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
conn = domain->conn;
@@ -10017,10 +9794,7 @@ virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
virCheckNonZeroArgGoto(nvcpus, error);
@@ -10093,10 +9867,7 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
if (flags & VIR_DOMAIN_VCPU_GUEST && flags & VIR_DOMAIN_VCPU_MAXIMUM) { @@ -10238,10 +10009,7 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu, virDispatchError(NULL); return -1; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
virCheckNonNullArgGoto(cpumap, error); virCheckPositiveArgGoto(maplen, error); @@ -10319,10 +10087,7 @@ virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu, return -1; }
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
virCheckNonNullArgGoto(cpumap, error); virCheckPositiveArgGoto(maplen, error); @@ -10477,10 +10242,7 @@ virDomainPinEmulator(virDomainPtr domain, unsigned char *cpumap, return -1; }
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error);
virCheckNonNullArgGoto(cpumap, error); virCheckPositiveArgGoto(maplen, error); @@ -10838,10 +10600,7 @@ virDomainSetMetadata(virDomainPtr domain,
conn = domain->conn;
- if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
switch (type) { case VIR_DOMAIN_METADATA_TITLE: @@ -11035,10 +10794,7 @@ virDomainAttachDevice(virDomainPtr domain, const char *xml)
virCheckNonNullArgGoto(xml, error);
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn;
if (conn->driver->domainAttachDevice) { @@ -11099,10 +10855,7 @@ virDomainAttachDeviceFlags(virDomainPtr domain,
virCheckNonNullArgGoto(xml, error);
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn;
if (conn->driver->domainAttachDeviceFlags) { @@ -11148,10 +10901,7 @@ virDomainDetachDevice(virDomainPtr domain, const char *xml)
virCheckNonNullArgGoto(xml, error);
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn;
if (conn->driver->domainDetachDevice) { @@ -11228,10 +10978,7 @@ virDomainDetachDeviceFlags(virDomainPtr domain,
virCheckNonNullArgGoto(xml, error);
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn;
if (conn->driver->domainDetachDeviceFlags) { @@ -11292,10 +11039,7 @@ virDomainUpdateDeviceFlags(virDomainPtr domain,
virCheckNonNullArgGoto(xml, error);
- if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(domain->conn->flags, error); conn = domain->conn;
if (conn->driver->domainUpdateDeviceFlags) { @@ -11783,10 +11527,7 @@ virNetworkCreateXML(virConnectPtr conn, const char *xmlDesc) } virCheckNonNullArgGoto(xmlDesc, error);
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->networkDriver && conn->networkDriver->networkCreateXML) { virNetworkPtr ret; @@ -11825,10 +11566,7 @@ virNetworkDefineXML(virConnectPtr conn, const char *xml) virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error);
if (conn->networkDriver && conn->networkDriver->networkDefineXML) { @@ -11869,10 +11607,7 @@ virNetworkUndefine(virNetworkPtr network) return -1; } conn = network->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibNetworkError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->networkDriver && conn->networkDriver->networkUndefine) { int ret; @@ -11929,10 +11664,7 @@ virNetworkUpdate(virNetworkPtr network, return -1; } conn = network->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibNetworkError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
virCheckNonNullArgGoto(xml, error);
@@ -11976,10 +11708,7 @@ virNetworkCreate(virNetworkPtr network) return -1; } conn = network->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibNetworkError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->networkDriver && conn->networkDriver->networkCreate) { int ret; @@ -12023,10 +11752,7 @@ virNetworkDestroy(virNetworkPtr network) }
conn = network->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibNetworkError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->networkDriver && conn->networkDriver->networkDestroy) { int ret; @@ -12356,10 +12082,7 @@ virNetworkSetAutostart(virNetworkPtr network, return -1; }
- if (network->conn->flags & VIR_CONNECT_RO) { - virLibNetworkError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(network->conn->flags, error);
conn = network->conn;
@@ -12859,10 +12582,7 @@ virInterfaceDefineXML(virConnectPtr conn, const char *xml, unsigned int flags) virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error);
if (conn->interfaceDriver && conn->interfaceDriver->interfaceDefineXML) { @@ -12914,10 +12634,7 @@ virInterfaceUndefine(virInterfacePtr iface) return -1; } conn = iface->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->interfaceDriver && conn->interfaceDriver->interfaceUndefine) { int ret; @@ -12963,10 +12680,7 @@ virInterfaceCreate(virInterfacePtr iface, unsigned int flags) return -1; } conn = iface->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->interfaceDriver && conn->interfaceDriver->interfaceCreate) { int ret; @@ -13017,10 +12731,7 @@ virInterfaceDestroy(virInterfacePtr iface, unsigned int flags) }
conn = iface->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->interfaceDriver && conn->interfaceDriver->interfaceDestroy) { int ret; @@ -13128,10 +12839,7 @@ virInterfaceChangeBegin(virConnectPtr conn, unsigned int flags) return -1; }
- if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->interfaceDriver && conn->interfaceDriver->interfaceChangeBegin) { int ret; @@ -13176,10 +12884,7 @@ virInterfaceChangeCommit(virConnectPtr conn, unsigned int flags) return -1; }
- if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->interfaceDriver && conn->interfaceDriver->interfaceChangeCommit) { int ret; @@ -13224,10 +12929,7 @@ virInterfaceChangeRollback(virConnectPtr conn, unsigned int flags) return -1; }
- if (conn->flags & VIR_CONNECT_RO) { - virLibInterfaceError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->interfaceDriver && conn->interfaceDriver->interfaceChangeRollback) { @@ -13578,10 +13280,7 @@ virConnectFindStoragePoolSources(virConnectPtr conn, } virCheckNonNullArgGoto(type, error);
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->storageDriver && conn->storageDriver->connectFindStoragePoolSources) { char *ret; @@ -13784,10 +13483,7 @@ virStoragePoolCreateXML(virConnectPtr conn, } virCheckNonNullArgGoto(xmlDesc, error);
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->storageDriver && conn->storageDriver->storagePoolCreateXML) { virStoragePoolPtr ret; @@ -13830,10 +13526,7 @@ virStoragePoolDefineXML(virConnectPtr conn, virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error);
if (conn->storageDriver && conn->storageDriver->storagePoolDefineXML) { @@ -13879,10 +13572,7 @@ virStoragePoolBuild(virStoragePoolPtr pool, return -1; } conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->storageDriver && conn->storageDriver->storagePoolBuild) { int ret; @@ -13922,10 +13612,7 @@ virStoragePoolUndefine(virStoragePoolPtr pool) return -1; } conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->storageDriver && conn->storageDriver->storagePoolUndefine) { int ret; @@ -13967,10 +13654,7 @@ virStoragePoolCreate(virStoragePoolPtr pool, return -1; } conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->storageDriver && conn->storageDriver->storagePoolCreate) { int ret; @@ -14015,10 +13699,7 @@ virStoragePoolDestroy(virStoragePoolPtr pool) }
conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->storageDriver && conn->storageDriver->storagePoolDestroy) { int ret; @@ -14063,10 +13744,7 @@ virStoragePoolDelete(virStoragePoolPtr pool, }
conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->storageDriver && conn->storageDriver->storagePoolDelete) { int ret; @@ -14172,10 +13850,7 @@ virStoragePoolRefresh(virStoragePoolPtr pool, }
conn = pool->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->storageDriver && conn->storageDriver->storagePoolRefresh) { int ret; @@ -14442,10 +14117,7 @@ virStoragePoolSetAutostart(virStoragePoolPtr pool, return -1; }
- if (pool->conn->flags & VIR_CONNECT_RO) { - virLibStoragePoolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(pool->conn->flags, error);
conn = pool->conn;
@@ -14839,10 +14511,7 @@ virStorageVolCreateXML(virStoragePoolPtr pool,
virCheckNonNullArgGoto(xmlDesc, error);
- if (pool->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(pool->conn->flags, error);
if (pool->conn->storageDriver && pool->conn->storageDriver->storageVolCreateXML) { virStorageVolPtr ret; @@ -14902,12 +14571,7 @@ virStorageVolCreateXMLFrom(virStoragePoolPtr pool, }
virCheckNonNullArgGoto(xmlDesc, error); - - if (pool->conn->flags & VIR_CONNECT_RO || - clonevol->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(pool->conn->flags | clonevol->conn->flags, error);
if (pool->conn->storageDriver && pool->conn->storageDriver->storageVolCreateXMLFrom) { @@ -14969,11 +14633,7 @@ virStorageVolDownload(virStorageVolPtr vol, return -1; }
- if (vol->conn->flags & VIR_CONNECT_RO || - stream->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(vol->conn->flags | stream->conn->flags, error);
if (vol->conn->storageDriver && vol->conn->storageDriver->storageVolDownload) { @@ -15040,11 +14700,7 @@ virStorageVolUpload(virStorageVolPtr vol, return -1; }
- if (vol->conn->flags & VIR_CONNECT_RO || - stream->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(vol->conn->flags | stream->conn->flags, error);
if (vol->conn->storageDriver && vol->conn->storageDriver->storageVolUpload) { @@ -15092,10 +14748,7 @@ virStorageVolDelete(virStorageVolPtr vol, }
conn = vol->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStorageVolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->storageDriver && conn->storageDriver->storageVolDelete) { int ret; @@ -15138,10 +14791,7 @@ virStorageVolWipe(virStorageVolPtr vol, }
conn = vol->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStorageVolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->storageDriver && conn->storageDriver->storageVolWipe) { int ret; @@ -15188,10 +14838,7 @@ virStorageVolWipePattern(virStorageVolPtr vol, }
conn = vol->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibStorageVolError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->storageDriver && conn->storageDriver->storageVolWipePattern) { int ret; @@ -15456,10 +15103,7 @@ virStorageVolResize(virStorageVolPtr vol,
conn = vol->conn;
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
/* Zero capacity is only valid with either delta or shrink. */ if (capacity == 0 && !((flags & VIR_STORAGE_VOL_RESIZE_DELTA) || @@ -16017,10 +15661,7 @@ virNodeDeviceDettach(virNodeDevicePtr dev) return -1; }
- if (dev->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dev->conn->flags, error);
if (dev->conn->driver->nodeDeviceDettach) { int ret; @@ -16082,10 +15723,7 @@ virNodeDeviceDetachFlags(virNodeDevicePtr dev, return -1; }
- if (dev->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dev->conn->flags, error);
if (dev->conn->driver->nodeDeviceDetachFlags) { int ret; @@ -16131,10 +15769,7 @@ virNodeDeviceReAttach(virNodeDevicePtr dev) return -1; }
- if (dev->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dev->conn->flags, error);
if (dev->conn->driver->nodeDeviceReAttach) { int ret; @@ -16182,10 +15817,7 @@ virNodeDeviceReset(virNodeDevicePtr dev) return -1; }
- if (dev->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dev->conn->flags, error);
if (dev->conn->driver->nodeDeviceReset) { int ret; @@ -16229,10 +15861,7 @@ virNodeDeviceCreateXML(virConnectPtr conn, return NULL; }
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
virCheckNonNullArgGoto(xmlDesc, error);
@@ -16275,10 +15904,7 @@ virNodeDeviceDestroy(virNodeDevicePtr dev) return -1; }
- if (dev->conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dev->conn->flags, error);
if (dev->conn->nodeDeviceDriver && dev->conn->nodeDeviceDriver->nodeDeviceDestroy) { @@ -16733,10 +16359,7 @@ virSecretDefineXML(virConnectPtr conn, const char *xml, unsigned int flags) virDispatchError(NULL); return NULL; } - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error);
if (conn->secretDriver != NULL && conn->secretDriver->secretDefineXML != NULL) { @@ -16955,10 +16578,7 @@ virSecretSetValue(virSecretPtr secret, const unsigned char *value, return -1; } conn = secret->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibSecretError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(value, error);
if (conn->secretDriver != NULL && conn->secretDriver->secretSetValue != NULL) { @@ -17004,10 +16624,7 @@ virSecretGetValue(virSecretPtr secret, size_t *value_size, unsigned int flags) return NULL; } conn = secret->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibSecretError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(value_size, error);
if (conn->secretDriver != NULL && conn->secretDriver->secretGetValue != NULL) { @@ -17051,10 +16668,7 @@ virSecretUndefine(virSecretPtr secret) return -1; } conn = secret->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibSecretError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->secretDriver != NULL && conn->secretDriver->secretUndefine != NULL) { int ret; @@ -18499,10 +18113,7 @@ virNWFilterDefineXML(virConnectPtr conn, const char *xmlDesc) } virCheckNonNullArgGoto(xmlDesc, error);
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterDefineXML) { virNWFilterPtr ret; @@ -18545,10 +18156,7 @@ virNWFilterUndefine(virNWFilterPtr nwfilter) }
conn = nwfilter->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibNWFilterError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterUndefine) { int ret; @@ -19040,10 +18648,7 @@ virDomainAbortJob(virDomainPtr domain) }
conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainAbortJob) { int ret; @@ -19091,10 +18696,7 @@ virDomainMigrateSetMaxDowntime(virDomainPtr domain, }
conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainMigrateSetMaxDowntime) { if (conn->driver->domainMigrateSetMaxDowntime(domain, downtime, flags) < 0) @@ -19187,10 +18789,7 @@ virDomainMigrateSetCompressionCache(virDomainPtr domain, }
conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainMigrateSetCompressionCache) { if (conn->driver->domainMigrateSetCompressionCache(domain, cacheSize, @@ -19236,10 +18835,7 @@ virDomainMigrateSetMaxSpeed(virDomainPtr domain, }
conn = domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainMigrateSetMaxSpeed) { if (conn->driver->domainMigrateSetMaxSpeed(domain, bandwidth, flags) < 0) @@ -19286,10 +18882,7 @@ virDomainMigrateGetMaxSpeed(virDomainPtr domain,
virCheckNonNullArgGoto(bandwidth, error);
- if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainMigrateGetMaxSpeed) { if (conn->driver->domainMigrateGetMaxSpeed(domain, bandwidth, flags) < 0) @@ -19597,10 +19190,7 @@ virDomainManagedSave(virDomainPtr dom, unsigned int flags) }
conn = dom->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if ((flags & VIR_DOMAIN_SAVE_RUNNING) && (flags & VIR_DOMAIN_SAVE_PAUSED)) { virReportInvalidArg(flags, @@ -19697,10 +19287,7 @@ virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) }
conn = dom->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainManagedSaveRemove) { int ret; @@ -19923,10 +19510,7 @@ virDomainSnapshotCreateXML(virDomainPtr domain,
virCheckNonNullArgGoto(xmlDesc, error);
- if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT) && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE)) { @@ -20854,10 +20438,7 @@ virDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, }
conn = snapshot->domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if ((flags & VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING) && (flags & VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) { @@ -20923,10 +20504,7 @@ virDomainSnapshotDelete(virDomainSnapshotPtr snapshot, }
conn = snapshot->domain->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if ((flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) && (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { @@ -21064,10 +20642,7 @@ virDomainOpenConsole(virDomainPtr dom, }
conn = dom->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainOpenConsole) { int ret; @@ -21127,10 +20702,7 @@ virDomainOpenChannel(virDomainPtr dom, }
conn = dom->conn; - if (conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(conn->flags, error);
if (conn->driver->domainOpenChannel) { int ret; @@ -21205,10 +20777,7 @@ virDomainBlockJobAbort(virDomainPtr dom, const char *disk, } conn = dom->conn;
- if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error);
virCheckNonNullArgGoto(disk, error);
@@ -21322,10 +20891,7 @@ virDomainBlockJobSetSpeed(virDomainPtr dom, const char *disk, } conn = dom->conn;
- if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error);
virCheckNonNullArgGoto(disk, error);
@@ -21396,10 +20962,7 @@ virDomainBlockPull(virDomainPtr dom, const char *disk, } conn = dom->conn;
- if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error);
virCheckNonNullArgGoto(disk, error);
@@ -21516,10 +21079,7 @@ virDomainBlockRebase(virDomainPtr dom, const char *disk, } conn = dom->conn;
- if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error);
virCheckNonNullArgGoto(disk, error);
@@ -21635,10 +21195,7 @@ virDomainBlockCommit(virDomainPtr dom, const char *disk, } conn = dom->conn;
- if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error);
virCheckNonNullArgGoto(disk, error);
@@ -21716,10 +21273,7 @@ virDomainOpenGraphics(virDomainPtr dom, goto error; }
- if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error);
if (!VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn, VIR_DRV_FEATURE_FD_PASSING)) { @@ -22007,10 +21561,7 @@ virDomainSetBlockIoTune(virDomainPtr dom, return -1; }
- if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error);
virCheckNonNullArgGoto(disk, error); virCheckPositiveArgGoto(nparams, error); @@ -22474,10 +22025,7 @@ virDomainFSTrim(virDomainPtr dom, return -1; }
- if (dom->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); - goto error; - } + virCheckReadOnlyGoto(dom->conn->flags, error);
if (dom->conn->driver->domainFSTrim) { int ret = dom->conn->driver->domainFSTrim(dom, mountPoint, diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index a6be43c..b4ed14b 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -1,7 +1,7 @@ /* * lock_daemon.c: lock management daemon * - * Copyright (C) 2006-2012 Red Hat, Inc. + * Copyright (C) 2006-2013 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -800,18 +800,16 @@ virLockDaemonClientNew(virNetServerClientPtr client,
if (!privileged) { if (geteuid() != clientuid) { - virReportError(VIR_ERR_OPERATION_DENIED, - _("Disallowing client %llu with uid %llu"), - (unsigned long long)priv->clientPid, - (unsigned long long)clientuid); + virReportRestrictedError(_("Disallowing client %llu with uid %llu"), + (unsigned long long)priv->clientPid, + (unsigned long long)clientuid); goto error; } } else { if (clientuid != 0) { - virReportError(VIR_ERR_OPERATION_DENIED, - _("Disallowing client %llu with uid %llu"), - (unsigned long long)priv->clientPid, - (unsigned long long)clientuid); + virReportRestrictedError(_("Disallowing client %llu with uid %llu"), + (unsigned long long)priv->clientPid, + (unsigned long long)clientuid); goto error; } } diff --git a/src/util/virerror.c b/src/util/virerror.c index d9a9fc4..877c15e 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -888,7 +888,7 @@ virErrorMsg(virErrorNumber error, const char *info) if (info == NULL) errmsg = _("operation forbidden for read only access"); else - errmsg = _("operation %s forbidden for read only access"); + errmsg = _("operation forbidden: %s"); break; case VIR_ERR_OPEN_FAILED: if (info == NULL) diff --git a/src/util/virerror.h b/src/util/virerror.h index ec7ef95..65c134c 100644 --- a/src/util/virerror.h +++ b/src/util/virerror.h @@ -159,6 +159,9 @@ void virReportSystemErrorFull(int domcode, # define virReportUnsupportedError() \ virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_NO_SUPPORT, \ __FILE__, __FUNCTION__, __LINE__, __FUNCTION__) +# define virReportRestrictedError(...) \ + virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_OPERATION_DENIED, \ + __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
void virReportOOMErrorFull(int domcode,

On 01/02/2014 04:08 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
Some of our operation denied messages are outright stupid; for example, if virIdentitySetAttr fails:
error: operation Identity attribute is already set forbidden for read only access
This patch fixes things to a saner:
error: operation forbidden: Identity attribute is already set
It also consolidates the most common usage pattern for operation denied errors: read-only connections preventing a public API. In this case, 'virsh -r -c test:///default destroy test' changes from:
error: operation virDomainDestroy forbidden for read only access
to:
error: operation forbidden: read only access prevents virDomainDestroy
Yet another case where in libvirt.c the error changes from VIR_FROM_xxxx to VIR_FROM_NONE (_THIS technically). Where xxxx is DOM, INTERFACE, STORAGE, etc.
Okay, I enhanced the commit message to document that this is intentional, and with no real loss in quality (similar to commit baa7244).
Not that it should matter, but it I figured it should be pointed out. Perhaps more so in this case, the failure is related directly to the connection rather than function...
ACK - for what's there.
Thanks; pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

The datatype.c object checks could result in a message like: error: invalid connection pointer in no connection This consolidates all clients of this message to have uniform contents: error: invalid connection pointer in someFunc * src/datatypes.h (virCheckConnectReturn) (virCheckConnectGoto): New macros. * src/datatypes.c: Use new macro. * src/libvirt-qemu.c (virDomainQemuAttach): Likewise. (virLibConnError): Delete unused macro. * src/libvirt-lxc.c (virLibConnError): Likewise. * src/libvirt.c: Use new macro throughout. * docs/api_extension.html.in: Modernize documentation. Signed-off-by: Eric Blake <eblake@redhat.com> --- docs/api_extension.html.in | 7 +- src/datatypes.c | 86 ++--- src/datatypes.h | 19 ++ src/libvirt-lxc.c | 4 - src/libvirt-qemu.c | 11 +- src/libvirt.c | 783 +++++++-------------------------------------- 6 files changed, 178 insertions(+), 732 deletions(-) diff --git a/docs/api_extension.html.in b/docs/api_extension.html.in index 6718625..ac7097b 100644 --- a/docs/api_extension.html.in +++ b/docs/api_extension.html.in @@ -180,12 +180,13 @@ being called and its parameters;</li> <li>MUST call virResetLastError();</li> <li>SHOULD confirm that the connection is valid with - VIR_IS_CONNECT(conn);</li> + virCheckConnectReturn() or virCheckConnectGoto();</li> <li><strong>SECURITY: If the API requires a connection with write privileges, MUST confirm that the connection flags do not - indicate that the connection is read-only;</strong></li> + indicate that the connection is read-only with + virCheckReadOnlyGoto();</strong></li> <li>SHOULD do basic validation of the parameters that are being - passed in;</li> + passed in, using helpers like virCheckNonNullArgGoto();</li> <li>MUST confirm that the driver for this connection exists and that it implements this function;</li> <li>MUST call the internal API;</li> diff --git a/src/datatypes.c b/src/datatypes.c index 161f1b0..b765ec8 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -1,7 +1,7 @@ /* * datatypes.h: management of structs for public data types * - * Copyright (C) 2006-2012 Red Hat, Inc. + * Copyright (C) 2006-2013 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -218,15 +218,12 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) if (virDataTypesInitialize() < 0) return NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection")); - return NULL; - } - virCheckNonNullArgReturn(name, NULL); - virCheckNonNullArgReturn(uuid, NULL); + virCheckConnectGoto(conn, error); + virCheckNonNullArgGoto(name, error); + virCheckNonNullArgGoto(uuid, error); if (!(ret = virObjectNew(virDomainClass))) - return NULL; + goto error; if (VIR_STRDUP(ret->name, name) < 0) goto error; @@ -289,15 +286,12 @@ virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid) if (virDataTypesInitialize() < 0) return NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection")); - return NULL; - } - virCheckNonNullArgReturn(name, NULL); - virCheckNonNullArgReturn(uuid, NULL); + virCheckConnectGoto(conn, error); + virCheckNonNullArgGoto(name, error); + virCheckNonNullArgGoto(uuid, error); if (!(ret = virObjectNew(virNetworkClass))) - return NULL; + goto error; if (VIR_STRDUP(ret->name, name) < 0) goto error; @@ -360,18 +354,15 @@ virGetInterface(virConnectPtr conn, const char *name, const char *mac) if (virDataTypesInitialize() < 0) return NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection")); - return NULL; - } - virCheckNonNullArgReturn(name, NULL); + virCheckConnectGoto(conn, error); + virCheckNonNullArgGoto(name, error); /* a NULL mac from caller is okay. Treat it as blank */ if (mac == NULL) mac = ""; if (!(ret = virObjectNew(virInterfaceClass))) - return NULL; + goto error; if (VIR_STRDUP(ret->name, name) < 0 || VIR_STRDUP(ret->mac, mac) < 0) @@ -435,15 +426,12 @@ virGetStoragePool(virConnectPtr conn, const char *name, if (virDataTypesInitialize() < 0) return NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection")); - return NULL; - } - virCheckNonNullArgReturn(name, NULL); - virCheckNonNullArgReturn(uuid, NULL); + virCheckConnectGoto(conn, error); + virCheckNonNullArgGoto(name, error); + virCheckNonNullArgGoto(uuid, error); if (!(ret = virObjectNew(virStoragePoolClass))) - return NULL; + goto error; if (VIR_STRDUP(ret->name, name) < 0) goto error; @@ -518,16 +506,13 @@ virGetStorageVol(virConnectPtr conn, const char *pool, const char *name, if (virDataTypesInitialize() < 0) return NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection")); - return NULL; - } - virCheckNonNullArgReturn(pool, NULL); - virCheckNonNullArgReturn(name, NULL); - virCheckNonNullArgReturn(key, NULL); + virCheckConnectGoto(conn, error); + virCheckNonNullArgGoto(pool, error); + virCheckNonNullArgGoto(name, error); + virCheckNonNullArgGoto(key, error); if (!(ret = virObjectNew(virStorageVolClass))) - return NULL; + goto error; if (VIR_STRDUP(ret->pool, pool) < 0 || VIR_STRDUP(ret->name, name) < 0 || @@ -597,14 +582,11 @@ virGetNodeDevice(virConnectPtr conn, const char *name) if (virDataTypesInitialize() < 0) return NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection")); - return NULL; - } - virCheckNonNullArgReturn(name, NULL); + virCheckConnectGoto(conn, error); + virCheckNonNullArgGoto(name, error); if (!(ret = virObjectNew(virNodeDeviceClass))) - return NULL; + goto error; if (VIR_STRDUP(ret->name, name) < 0) goto error; @@ -664,12 +646,9 @@ virGetSecret(virConnectPtr conn, const unsigned char *uuid, if (virDataTypesInitialize() < 0) return NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection")); - return NULL; - } - virCheckNonNullArgReturn(uuid, NULL); - virCheckNonNullArgReturn(usageID, NULL); + virCheckConnectGoto(conn, error); + virCheckNonNullArgGoto(uuid, error); + virCheckNonNullArgGoto(usageID, error); if (!(ret = virObjectNew(virSecretClass))) return NULL; @@ -761,15 +740,12 @@ virGetNWFilter(virConnectPtr conn, const char *name, if (virDataTypesInitialize() < 0) return NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection")); - return NULL; - } - virCheckNonNullArgReturn(name, NULL); - virCheckNonNullArgReturn(uuid, NULL); + virCheckConnectGoto(conn, error); + virCheckNonNullArgGoto(name, error); + virCheckNonNullArgGoto(uuid, error); if (!(ret = virObjectNew(virNWFilterClass))) - return NULL; + goto error; if (VIR_STRDUP(ret->name, name) < 0) goto error; diff --git a/src/datatypes.h b/src/datatypes.h index 7f325b0..cb0a5d9 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -42,6 +42,25 @@ extern virClassPtr virStoragePoolClass; # define VIR_IS_CONNECT(obj) \ (virObjectIsClass((obj), virConnectClass)) +# define virCheckConnectReturn(obj, retval) \ + do { \ + if (!VIR_IS_CONNECT(obj)) { \ + virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INVALID_CONN, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) +# define virCheckConnectGoto(obj, label) \ + do { \ + if (!VIR_IS_CONNECT(obj)) { \ + virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INVALID_CONN, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + goto label; \ + } \ + } while (0) # define VIR_IS_DOMAIN(obj) \ (virObjectIsClass((obj), virDomainClass)) diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index fc56a58..ae8bc88 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -36,10 +36,6 @@ #define VIR_FROM_THIS VIR_FROM_NONE -#define virLibConnError(conn, error, info) \ - virReportErrorHelper(VIR_FROM_NONE, error, __FILE__, __FUNCTION__, \ - __LINE__, info) - #define virLibDomainError(domain, error, info) \ virReportErrorHelper(VIR_FROM_DOM, error, __FILE__, __FUNCTION__, \ __LINE__, info) diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 4aaff39..79e8e6b 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -30,10 +30,6 @@ #define VIR_FROM_THIS VIR_FROM_NONE -#define virLibConnError(conn, error, info) \ - virReportErrorHelper(VIR_FROM_NONE, error, __FILE__, __FUNCTION__, \ - __LINE__, info) - #define virLibDomainError(domain, error, info) \ virReportErrorHelper(VIR_FROM_DOM, error, __FILE__, __FUNCTION__, \ __LINE__, info) @@ -149,12 +145,7 @@ virDomainQemuAttach(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckConnectReturn(conn, NULL); virCheckPositiveArgGoto(pid_value, error); if (pid != pid_value) { virReportInvalidArg(pid_value, diff --git a/src/libvirt.c b/src/libvirt.c index 6d1601f..e0b0b32 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1492,23 +1492,15 @@ error: int virConnectClose(virConnectPtr conn) { - int ret = -1; VIR_DEBUG("conn=%p", conn); virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - goto error; - } + virCheckConnectReturn(conn, -1); if (!virObjectUnref(conn)) return 0; return 1; - -error: - virDispatchError(NULL); - return ret; } @@ -1536,11 +1528,7 @@ virConnectRef(virConnectPtr conn) virResetLastError(); - if ((!VIR_IS_CONNECT(conn))) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virObjectRef(conn); return 0; } @@ -1558,11 +1546,7 @@ virConnectSupportsFeature(virConnectPtr conn, int feature) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (!conn->driver->connectSupportsFeature) ret = 0; @@ -1599,11 +1583,7 @@ virConnectGetType(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); if (conn->driver->connectGetType) { ret = conn->driver->connectGetType(conn); @@ -1633,12 +1613,7 @@ virConnectGetVersion(virConnectPtr conn, unsigned long *hvVer) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(hvVer, error); if (conn->driver->connectGetVersion) { @@ -1675,12 +1650,7 @@ virConnectGetLibVersion(virConnectPtr conn, unsigned long *libVer) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(libVer, error); if (conn->driver->connectGetLibVersion) { @@ -1719,11 +1689,7 @@ virConnectGetHostname(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); if (conn->driver->connectGetHostname) { char *ret = conn->driver->connectGetHostname(conn); @@ -1763,11 +1729,7 @@ virConnectGetURI(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); if (!(name = virURIFormat(conn->uri))) goto error; @@ -1800,11 +1762,7 @@ virConnectGetSysinfo(virConnectPtr conn, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); if (conn->driver->connectGetSysinfo) { char *ret = conn->driver->connectGetSysinfo(conn, flags); @@ -1840,11 +1798,7 @@ virConnectGetMaxVcpus(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->driver->connectGetMaxVcpus) { int ret = conn->driver->connectGetMaxVcpus(conn, type); @@ -1884,12 +1838,7 @@ virConnectListDomains(virConnectPtr conn, int *ids, int maxids) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(ids, error); virCheckNonNegativeArgGoto(maxids, error); @@ -1922,11 +1871,7 @@ virConnectNumOfDomains(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->driver->connectNumOfDomains) { int ret = conn->driver->connectNumOfDomains(conn); @@ -2006,11 +1951,7 @@ virDomainCreateXML(virConnectPtr conn, const char *xmlDesc, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(xmlDesc, error); virCheckReadOnlyGoto(conn->flags, error); @@ -2075,11 +2016,7 @@ virDomainCreateXMLWithFiles(virConnectPtr conn, const char *xmlDesc, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(xmlDesc, error); virCheckReadOnlyGoto(conn->flags, error); @@ -2139,11 +2076,7 @@ virDomainLookupByID(virConnectPtr conn, int id) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNegativeArgGoto(id, error); if (conn->driver->domainLookupByID) { @@ -2179,11 +2112,7 @@ virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(uuid, error); if (conn->driver->domainLookupByUUID) { @@ -2220,11 +2149,7 @@ virDomainLookupByUUIDString(virConnectPtr conn, const char *uuidstr) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(uuidstr, error); if (virUUIDParse(uuidstr, uuid) < 0) { @@ -2259,11 +2184,7 @@ virDomainLookupByName(virConnectPtr conn, const char *name) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(name, error); if (conn->driver->domainLookupByName) { @@ -2846,11 +2767,7 @@ virDomainRestore(virConnectPtr conn, const char *from) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(from, error); @@ -2920,11 +2837,7 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(from, error); @@ -2990,11 +2903,7 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(file, error); if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) { @@ -3067,11 +2976,7 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(file, error); virCheckNonNullArgGoto(dxml, error); @@ -4587,11 +4492,7 @@ char *virConnectDomainXMLFromNative(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(nativeFormat, error); @@ -4640,11 +4541,7 @@ char *virConnectDomainXMLToNative(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(nativeFormat, error); @@ -5500,10 +5397,7 @@ virDomainMigrate(virDomainPtr domain, virCheckReadOnlyGoto(domain->conn->flags, error); /* Now checkout the destination */ - if (!VIR_IS_CONNECT(dconn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - goto error; - } + virCheckConnectGoto(dconn, error); virCheckReadOnlyGoto(dconn->flags, error); if (flags & VIR_MIGRATE_NON_SHARED_DISK && @@ -5733,10 +5627,7 @@ virDomainMigrate2(virDomainPtr domain, virCheckReadOnlyGoto(domain->conn->flags, error); /* Now checkout the destination */ - if (!VIR_IS_CONNECT(dconn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - goto error; - } + virCheckConnectGoto(dconn, error); virCheckReadOnlyGoto(dconn->flags, error); if (flags & VIR_MIGRATE_NON_SHARED_DISK && @@ -5917,10 +5808,7 @@ virDomainMigrate3(virDomainPtr domain, virCheckReadOnlyGoto(domain->conn->flags, error); /* Now checkout the destination */ - if (!VIR_IS_CONNECT(dconn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - goto error; - } + virCheckConnectGoto(dconn, error); virCheckReadOnlyGoto(dconn->flags, error); if (flags & VIR_MIGRATE_NON_SHARED_DISK && @@ -6519,12 +6407,7 @@ virDomainMigratePrepare(virConnectPtr dconn, virResetLastError(); - if (!VIR_IS_CONNECT(dconn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(dconn, -1); virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigratePrepare) { @@ -6611,12 +6494,7 @@ virDomainMigrateFinish(virConnectPtr dconn, virResetLastError(); - if (!VIR_IS_CONNECT(dconn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckConnectReturn(dconn, NULL); virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigrateFinish) { @@ -6659,12 +6537,7 @@ virDomainMigratePrepare2(virConnectPtr dconn, virResetLastError(); - if (!VIR_IS_CONNECT(dconn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(dconn, -1); virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigratePrepare2) { @@ -6705,12 +6578,7 @@ virDomainMigrateFinish2(virConnectPtr dconn, virResetLastError(); - if (!VIR_IS_CONNECT(dconn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckConnectReturn(dconn, NULL); virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigrateFinish2) { @@ -6750,12 +6618,7 @@ virDomainMigratePrepareTunnel(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckReadOnlyGoto(conn->flags, error); if (conn != st->conn) { @@ -6857,12 +6720,7 @@ virDomainMigratePrepare3(virConnectPtr dconn, virResetLastError(); - if (!VIR_IS_CONNECT(dconn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(dconn, -1); virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigratePrepare3) { @@ -6910,12 +6768,7 @@ virDomainMigratePrepareTunnel3(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckReadOnlyGoto(conn->flags, error); if (conn != st->conn) { @@ -7024,12 +6877,7 @@ virDomainMigrateFinish3(virConnectPtr dconn, virResetLastError(); - if (!VIR_IS_CONNECT(dconn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckConnectReturn(dconn, NULL); virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigrateFinish3) { @@ -7170,12 +7018,7 @@ virDomainMigratePrepare3Params(virConnectPtr dconn, virResetLastError(); - if (!VIR_IS_CONNECT(dconn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(dconn, -1); virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigratePrepare3Params) { @@ -7220,12 +7063,7 @@ virDomainMigratePrepareTunnel3Params(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckReadOnlyGoto(conn->flags, error); if (conn != st->conn) { @@ -7328,12 +7166,7 @@ virDomainMigrateFinish3Params(virConnectPtr dconn, virResetLastError(); - if (!VIR_IS_CONNECT(dconn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckConnectReturn(dconn, NULL); virCheckReadOnlyGoto(dconn->flags, error); if (dconn->driver->domainMigrateFinish3Params) { @@ -7419,11 +7252,7 @@ virNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(info, error); if (conn->driver->nodeGetInfo) { @@ -7459,11 +7288,7 @@ virConnectGetCapabilities(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); if (conn->driver->connectGetCapabilities) { char *ret; @@ -7547,12 +7372,7 @@ virNodeGetCPUStats(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(nparams, error); virCheckNonNegativeArgGoto(*nparams, error); if (((cpuNum < 0) && (cpuNum != VIR_NODE_CPU_STATS_ALL_CPUS))) { @@ -7638,12 +7458,7 @@ virNodeGetMemoryStats(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(nparams, error); virCheckNonNegativeArgGoto(*nparams, error); if (((cellNum < 0) && (cellNum != VIR_NODE_MEMORY_STATS_ALL_CELLS))) { @@ -7685,11 +7500,7 @@ virNodeGetFreeMemory(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return 0; - } + virCheckConnectReturn(conn, 0); if (conn->driver->nodeGetFreeMemory) { unsigned long long ret; @@ -7739,12 +7550,7 @@ virNodeSuspendForDuration(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->nodeSuspendForDuration) { @@ -7797,12 +7603,7 @@ virNodeGetMemoryParameters(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(nparams, error); virCheckNonNegativeArgGoto(*nparams, error); if (*nparams != 0) @@ -7862,14 +7663,8 @@ virNodeSetMemoryParameters(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckReadOnlyGoto(conn->flags, error); - virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error); @@ -8977,11 +8772,7 @@ virDomainDefineXML(virConnectPtr conn, const char *xml) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); @@ -9122,11 +8913,7 @@ virConnectNumOfDefinedDomains(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->driver->connectNumOfDefinedDomains) { int ret; @@ -9170,12 +8957,7 @@ virConnectListDefinedDomains(virConnectPtr conn, char **const names, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(names, error); virCheckNonNegativeArgGoto(maxnames, error); @@ -9279,11 +9061,7 @@ virConnectListAllDomains(virConnectPtr conn, if (domains) *domains = NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->driver->connectListAllDomains) { int ret; @@ -10739,12 +10517,7 @@ virNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(secmodel, error); if (conn->driver->nodeGetSecurityModel) { @@ -11084,12 +10857,7 @@ virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(freeMems, error); virCheckPositiveArgGoto(maxCells, error); virCheckNonNegativeArgGoto(startCell, error); @@ -11187,11 +10955,7 @@ virConnectListAllNetworks(virConnectPtr conn, if (nets) *nets = NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->networkDriver && conn->networkDriver->connectListAllNetworks) { @@ -11225,11 +10989,7 @@ virConnectNumOfNetworks(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->networkDriver && conn->networkDriver->connectNumOfNetworks) { int ret; @@ -11270,12 +11030,7 @@ virConnectListNetworks(virConnectPtr conn, char **const names, int maxnames) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(names, error); virCheckNonNegativeArgGoto(maxnames, error); @@ -11310,11 +11065,7 @@ virConnectNumOfDefinedNetworks(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->networkDriver && conn->networkDriver->connectNumOfDefinedNetworks) { int ret; @@ -11356,12 +11107,7 @@ virConnectListDefinedNetworks(virConnectPtr conn, char **const names, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(names, error); virCheckNonNegativeArgGoto(maxnames, error); @@ -11398,11 +11144,7 @@ virNetworkLookupByName(virConnectPtr conn, const char *name) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(name, error); if (conn->networkDriver && conn->networkDriver->networkLookupByName) { @@ -11438,12 +11180,7 @@ virNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(uuid, error); if (conn->networkDriver && conn->networkDriver->networkLookupByUUID){ @@ -11480,12 +11217,7 @@ virNetworkLookupByUUIDString(virConnectPtr conn, const char *uuidstr) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(uuidstr, error); if (virUUIDParse(uuidstr, uuid) < 0) { @@ -11520,13 +11252,8 @@ virNetworkCreateXML(virConnectPtr conn, const char *xmlDesc) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(xmlDesc, error); - virCheckReadOnlyGoto(conn->flags, error); if (conn->networkDriver && conn->networkDriver->networkCreateXML) { @@ -11561,11 +11288,7 @@ virNetworkDefineXML(virConnectPtr conn, const char *xml) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); @@ -12171,11 +11894,7 @@ virConnectListAllInterfaces(virConnectPtr conn, if (ifaces) *ifaces = NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->interfaceDriver && conn->interfaceDriver->connectListAllInterfaces) { @@ -12209,11 +11928,7 @@ virConnectNumOfInterfaces(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->interfaceDriver && conn->interfaceDriver->connectNumOfInterfaces) { int ret; @@ -12255,12 +11970,7 @@ virConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(names, error); virCheckNonNegativeArgGoto(maxnames, error); @@ -12295,11 +12005,7 @@ virConnectNumOfDefinedInterfaces(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->interfaceDriver && conn->interfaceDriver->connectNumOfDefinedInterfaces) { int ret; @@ -12343,12 +12049,7 @@ virConnectListDefinedInterfaces(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(names, error); virCheckNonNegativeArgGoto(maxnames, error); @@ -12385,11 +12086,7 @@ virInterfaceLookupByName(virConnectPtr conn, const char *name) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(name, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceLookupByName) { @@ -12425,11 +12122,7 @@ virInterfaceLookupByMACString(virConnectPtr conn, const char *macstr) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(macstr, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceLookupByMACString) { @@ -12577,11 +12270,7 @@ virInterfaceDefineXML(virConnectPtr conn, const char *xml, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); @@ -12833,12 +12522,7 @@ virInterfaceChangeBegin(virConnectPtr conn, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceChangeBegin) { @@ -12878,12 +12562,7 @@ virInterfaceChangeCommit(virConnectPtr conn, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceChangeCommit) { @@ -12923,12 +12602,7 @@ virInterfaceChangeRollback(virConnectPtr conn, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && @@ -13040,11 +12714,7 @@ virConnectListAllStoragePools(virConnectPtr conn, if (pools) *pools = NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->storageDriver && conn->storageDriver->connectListAllStoragePools) { @@ -13078,11 +12748,7 @@ virConnectNumOfStoragePools(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->storageDriver && conn->storageDriver->connectNumOfStoragePools) { int ret; @@ -13127,12 +12793,7 @@ virConnectListStoragePools(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(names, error); virCheckNonNegativeArgGoto(maxnames, error); @@ -13167,11 +12828,7 @@ virConnectNumOfDefinedStoragePools(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->storageDriver && conn->storageDriver->connectNumOfDefinedStoragePools) { int ret; @@ -13216,12 +12873,7 @@ virConnectListDefinedStoragePools(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(names, error); virCheckNonNegativeArgGoto(maxnames, error); @@ -13273,13 +12925,8 @@ virConnectFindStoragePoolSources(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(type, error); - virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->connectFindStoragePoolSources) { @@ -13315,11 +12962,7 @@ virStoragePoolLookupByName(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(name, error); if (conn->storageDriver && conn->storageDriver->storagePoolLookupByName) { @@ -13355,11 +12998,7 @@ virStoragePoolLookupByUUID(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(uuid, error); if (conn->storageDriver && conn->storageDriver->storagePoolLookupByUUID) { @@ -13396,11 +13035,7 @@ virStoragePoolLookupByUUIDString(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(uuidstr, error); if (virUUIDParse(uuidstr, uuid) < 0) { @@ -13476,13 +13111,8 @@ virStoragePoolCreateXML(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(xmlDesc, error); - virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolCreateXML) { @@ -13521,11 +13151,7 @@ virStoragePoolDefineXML(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); @@ -14361,12 +13987,7 @@ virStorageVolLookupByKey(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(key, error); if (conn->storageDriver && conn->storageDriver->storageVolLookupByKey) { @@ -14403,11 +14024,7 @@ virStorageVolLookupByPath(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(path, error); if (conn->storageDriver && conn->storageDriver->storageVolLookupByPath) { @@ -15150,11 +14767,7 @@ virNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->nodeDeviceDriver && conn->nodeDeviceDriver->nodeNumOfDevices) { int ret; @@ -15223,11 +14836,7 @@ virConnectListAllNodeDevices(virConnectPtr conn, if (devices) *devices = NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->nodeDeviceDriver && conn->nodeDeviceDriver->connectListAllNodeDevices) { @@ -15274,11 +14883,7 @@ virNodeListDevices(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(names, error); virCheckNonNegativeArgGoto(maxnames, error); @@ -15314,12 +14919,7 @@ virNodeDeviceLookupByName(virConnectPtr conn, const char *name) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(name, error); if (conn->nodeDeviceDriver && conn->nodeDeviceDriver->nodeDeviceLookupByName) { @@ -15359,12 +14959,7 @@ virNodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(wwnn, error); virCheckNonNullArgGoto(wwpn, error); @@ -15855,14 +15450,8 @@ virNodeDeviceCreateXML(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckConnectReturn(conn, NULL); virCheckReadOnlyGoto(conn->flags, error); - virCheckNonNullArgGoto(xmlDesc, error); if (conn->nodeDeviceDriver && @@ -15960,11 +15549,7 @@ virConnectDomainEventRegister(virConnectPtr conn, VIR_DEBUG("conn=%p, cb=%p, opaque=%p, freecb=%p", conn, cb, opaque, freecb); virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(cb, error); if ((conn->driver) && (conn->driver->connectDomainEventRegister)) { @@ -16004,11 +15589,7 @@ virConnectDomainEventDeregister(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(cb, error); if ((conn->driver) && (conn->driver->connectDomainEventDeregister)) { @@ -16069,11 +15650,7 @@ virConnectNumOfSecrets(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->secretDriver != NULL && conn->secretDriver->connectNumOfSecrets != NULL) { @@ -16138,11 +15715,7 @@ virConnectListAllSecrets(virConnectPtr conn, if (secrets) *secrets = NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->secretDriver && conn->secretDriver->connectListAllSecrets) { @@ -16178,11 +15751,7 @@ virConnectListSecrets(virConnectPtr conn, char **uuids, int maxuuids) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(uuids, error); virCheckNonNegativeArgGoto(maxuuids, error); @@ -16221,11 +15790,7 @@ virSecretLookupByUUID(virConnectPtr conn, const unsigned char *uuid) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(uuid, error); if (conn->secretDriver && @@ -16264,11 +15829,7 @@ virSecretLookupByUUIDString(virConnectPtr conn, const char *uuidstr) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(uuidstr, error); if (virUUIDParse(uuidstr, uuid) < 0) { @@ -16308,11 +15869,7 @@ virSecretLookupByUsage(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(usageID, error); if (conn->secretDriver && @@ -16354,11 +15911,7 @@ virSecretDefineXML(virConnectPtr conn, const char *xml, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); @@ -16775,11 +16328,7 @@ virStreamNew(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); st = virGetStream(conn); if (st) @@ -17735,11 +17284,7 @@ virConnectNumOfNWFilters(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->nwfilterDriver && conn->nwfilterDriver->connectNumOfNWFilters) { int ret; @@ -17786,11 +17331,7 @@ virConnectListAllNWFilters(virConnectPtr conn, if (filters) *filters = NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->nwfilterDriver && conn->nwfilterDriver->connectListAllNWFilters) { @@ -17826,12 +17367,7 @@ virConnectListNWFilters(virConnectPtr conn, char **const names, int maxnames) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(names, error); virCheckNonNegativeArgGoto(maxnames, error); @@ -17868,11 +17404,7 @@ virNWFilterLookupByName(virConnectPtr conn, const char *name) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(name, error); if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterLookupByName) { @@ -17908,11 +17440,7 @@ virNWFilterLookupByUUID(virConnectPtr conn, const unsigned char *uuid) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(uuid, error); if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterLookupByUUID){ @@ -17949,11 +17477,7 @@ virNWFilterLookupByUUIDString(virConnectPtr conn, const char *uuidstr) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(uuidstr, error); if (virUUIDParse(uuidstr, uuid) < 0) { @@ -18106,13 +17630,8 @@ virNWFilterDefineXML(virConnectPtr conn, const char *xmlDesc) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(xmlDesc, error); - virCheckReadOnlyGoto(conn->flags, error); if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterDefineXML) { @@ -18302,11 +17821,7 @@ virConnectIsEncrypted(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->driver->connectIsEncrypted) { int ret; ret = conn->driver->connectIsEncrypted(conn); @@ -18341,11 +17856,7 @@ virConnectIsSecure(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->driver->connectIsSecure) { int ret; ret = conn->driver->connectIsSecure(conn); @@ -18380,11 +17891,7 @@ virConnectCompareCPU(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return VIR_CPU_COMPARE_ERROR; - } + virCheckConnectReturn(conn, VIR_CPU_COMPARE_ERROR); virCheckNonNullArgGoto(xmlDesc, error); if (conn->driver->connectCompareCPU) { @@ -18430,11 +17937,7 @@ virConnectGetCPUModelNames(virConnectPtr conn, const char *arch, char ***models, if (models) *models = NULL; - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virCheckNonNullArgGoto(arch, error); if (conn->driver->connectGetCPUModelNames) { @@ -18490,11 +17993,7 @@ virConnectBaselineCPU(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckConnectReturn(conn, NULL); virCheckNonNullArgGoto(xmlCPUs, error); if (conn->driver->connectBaselineCPU) { @@ -18943,11 +18442,7 @@ virConnectDomainEventRegisterAny(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (dom != NULL && !(VIR_IS_CONNECTED_DOMAIN(dom) && dom->conn == conn)) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); @@ -18996,11 +18491,7 @@ virConnectDomainEventDeregisterAny(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virCheckNonNegativeArgGoto(callbackID, error); if ((conn->driver) && (conn->driver->connectDomainEventDeregisterAny)) { @@ -19064,11 +18555,7 @@ virConnectNetworkEventRegisterAny(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (net != NULL && !(VIR_IS_CONNECTED_NETWORK(net) && net->conn == conn)) { virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); @@ -19121,11 +18608,7 @@ virConnectNetworkEventDeregisterAny(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virCheckNonNegativeArgGoto(callbackID, error); if ((conn->networkDriver) && @@ -21333,11 +20816,7 @@ virConnectSetKeepAlive(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->driver->connectSetKeepAlive) { ret = conn->driver->connectSetKeepAlive(conn, interval, count); @@ -21372,11 +20851,7 @@ virConnectIsAlive(virConnectPtr conn) virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->driver->connectIsAlive) { int ret; ret = conn->driver->connectIsAlive(conn); @@ -21425,11 +20900,7 @@ virConnectRegisterCloseCallback(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virObjectRef(conn); @@ -21484,11 +20955,7 @@ virConnectUnregisterCloseCallback(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); virMutexLock(&conn->lock); virObjectLock(conn->closeCallback); @@ -21968,11 +21435,7 @@ virNodeGetCPUMap(virConnectPtr conn, virResetLastError(); - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckConnectReturn(conn, -1); if (conn->driver->nodeGetCPUMap) { int ret = conn->driver->nodeGetCPUMap(conn, cpumap, online, flags); -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
The datatype.c object checks could result in a message like:
error: invalid connection pointer in no connection
This consolidates all clients of this message to have uniform contents:
error: invalid connection pointer in someFunc
* src/datatypes.h (virCheckConnectReturn) (virCheckConnectGoto): New macros. * src/datatypes.c: Use new macro. * src/libvirt-qemu.c (virDomainQemuAttach): Likewise. (virLibConnError): Delete unused macro. * src/libvirt-lxc.c (virLibConnError): Likewise. * src/libvirt.c: Use new macro throughout. * docs/api_extension.html.in: Modernize documentation.
Signed-off-by: Eric Blake <eblake@redhat.com> --- docs/api_extension.html.in | 7 +- src/datatypes.c | 86 ++--- src/datatypes.h | 19 ++ src/libvirt-lxc.c | 4 - src/libvirt-qemu.c | 11 +- src/libvirt.c | 783 +++++++-------------------------------------- 6 files changed, 178 insertions(+), 732 deletions(-)
ACK John

On 01/02/2014 04:32 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
The datatype.c object checks could result in a message like:
error: invalid connection pointer in no connection
This consolidates all clients of this message to have uniform contents:
error: invalid connection pointer in someFunc
ACK
Thanks; pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Cleanup after the previous patch. * src/datatypes.h (VIR_IS_CONNECT): Delete, and inline into all callers, since no other file uses it any more. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index cb0a5d9..e3d8da0 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -40,11 +40,9 @@ extern virClassPtr virStreamClass; extern virClassPtr virStorageVolClass; extern virClassPtr virStoragePoolClass; -# define VIR_IS_CONNECT(obj) \ - (virObjectIsClass((obj), virConnectClass)) # define virCheckConnectReturn(obj, retval) \ do { \ - if (!VIR_IS_CONNECT(obj)) { \ + if (!virObjectIsClass(obj, virConnectClass)) { \ virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INVALID_CONN, \ __FILE__, __FUNCTION__, __LINE__, \ __FUNCTION__); \ @@ -54,7 +52,7 @@ extern virClassPtr virStoragePoolClass; } while (0) # define virCheckConnectGoto(obj, label) \ do { \ - if (!VIR_IS_CONNECT(obj)) { \ + if (!virObjectIsClass(obj, virConnectClass)) { \ virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INVALID_CONN, \ __FILE__, __FUNCTION__, __LINE__, \ __FUNCTION__); \ @@ -65,47 +63,47 @@ extern virClassPtr virStoragePoolClass; # define VIR_IS_DOMAIN(obj) \ (virObjectIsClass((obj), virDomainClass)) # define VIR_IS_CONNECTED_DOMAIN(obj) \ - (VIR_IS_DOMAIN(obj) && VIR_IS_CONNECT((obj)->conn)) + (VIR_IS_DOMAIN(obj) && virObjectIsClass((obj)->conn, virConnectClass)) # define VIR_IS_NETWORK(obj) \ (virObjectIsClass((obj), virNetworkClass)) # define VIR_IS_CONNECTED_NETWORK(obj) \ - (VIR_IS_NETWORK(obj) && VIR_IS_CONNECT((obj)->conn)) + (VIR_IS_NETWORK(obj) && virObjectIsClass((obj)->conn, virConnectClass)) # define VIR_IS_INTERFACE(obj) \ (virObjectIsClass((obj), virInterfaceClass)) # define VIR_IS_CONNECTED_INTERFACE(obj) \ - (VIR_IS_INTERFACE(obj) && VIR_IS_CONNECT((obj)->conn)) + (VIR_IS_INTERFACE(obj) && virObjectIsClass((obj)->conn, virConnectClass)) # define VIR_IS_STORAGE_POOL(obj) \ (virObjectIsClass((obj), virStoragePoolClass)) # define VIR_IS_CONNECTED_STORAGE_POOL(obj) \ - (VIR_IS_STORAGE_POOL(obj) && VIR_IS_CONNECT((obj)->conn)) + (VIR_IS_STORAGE_POOL(obj) && virObjectIsClass((obj)->conn, virConnectClass)) # define VIR_IS_STORAGE_VOL(obj) \ (virObjectIsClass((obj), virStorageVolClass)) # define VIR_IS_CONNECTED_STORAGE_VOL(obj) \ - (VIR_IS_STORAGE_VOL(obj) && VIR_IS_CONNECT((obj)->conn)) + (VIR_IS_STORAGE_VOL(obj) && virObjectIsClass((obj)->conn, virConnectClass)) # define VIR_IS_NODE_DEVICE(obj) \ (virObjectIsClass((obj), virNodeDeviceClass)) # define VIR_IS_CONNECTED_NODE_DEVICE(obj) \ - (VIR_IS_NODE_DEVICE(obj) && VIR_IS_CONNECT((obj)->conn)) + (VIR_IS_NODE_DEVICE(obj) && virObjectIsClass((obj)->conn, virConnectClass)) # define VIR_IS_SECRET(obj) \ (virObjectIsClass((obj), virSecretClass)) # define VIR_IS_CONNECTED_SECRET(obj) \ - (VIR_IS_SECRET(obj) && VIR_IS_CONNECT((obj)->conn)) + (VIR_IS_SECRET(obj) && virObjectIsClass((obj)->conn, virConnectClass)) # define VIR_IS_STREAM(obj) \ (virObjectIsClass((obj), virStreamClass)) # define VIR_IS_CONNECTED_STREAM(obj) \ - (VIR_IS_STREAM(obj) && VIR_IS_CONNECT((obj)->conn)) + (VIR_IS_STREAM(obj) && virObjectIsClass((obj)->conn, virConnectClass)) # define VIR_IS_NWFILTER(obj) \ (virObjectIsClass((obj), virNWFilterClass)) # define VIR_IS_CONNECTED_NWFILTER(obj) \ - (VIR_IS_NWFILTER(obj) && VIR_IS_CONNECT((obj)->conn)) + (VIR_IS_NWFILTER(obj) && virObjectIsClass((obj)->conn, virConnectClass)) # define VIR_IS_SNAPSHOT(obj) \ (virObjectIsClass((obj), virDomainSnapshotClass)) -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
Cleanup after the previous patch.
* src/datatypes.h (VIR_IS_CONNECT): Delete, and inline into all callers, since no other file uses it any more.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
ACK John

On 01/02/2014 04:35 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
Cleanup after the previous patch.
* src/datatypes.h (VIR_IS_CONNECT): Delete, and inline into all callers, since no other file uses it any more.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
ACK
Pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

In datatype.c, virGetDomainSnapshot could result in the message: error: invalid domain pointer in bad domain Furthermore, while there are a few functions in libvirt.c that only care about a virDomainPtr without regards to the connection (such as virDomainGetName), most functions also require a valid connection. Yet several functions were blindly derefencing the conn member without checking it for validity first (such as virDomainOpenConsole). Rather than try and correct all usage of VIR_IS_DOMAIN vs. VIR_IS_CONNECTED_DOMAIN, it is easier to just blindly require that a valid domain object always has a valid connection object (which should be true anyways, since every domain object holds a reference to its connection, so the connection will not be closed until all domain objects have also been closed to release their reference). After this patch, all places that validate a domain consistently report: error: invalid domain pointer in someFunc * src/datatypes.h (virCheckDomainReturn, virCheckDomainGoto): New macros. * src/datatypes.c (virGetDomainSnapshot): Use new macro. (virLibConnError): Delete unused macro. Signed-off-by: Eric Blake <eblake@redhat.com> --- po/POTFILES.in | 1 - src/datatypes.c | 18 +- src/datatypes.h | 23 ++ src/libvirt-lxc.c | 11 +- src/libvirt-qemu.c | 18 +- src/libvirt.c | 1055 +++++++++++++--------------------------------------- 6 files changed, 284 insertions(+), 842 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 49dfc9c..0359b2f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -32,7 +32,6 @@ src/cpu/cpu_generic.c src/cpu/cpu_map.c src/cpu/cpu_powerpc.c src/cpu/cpu_x86.c -src/datatypes.c src/driver.c src/esx/esx_driver.c src/esx/esx_network_driver.c diff --git a/src/datatypes.c b/src/datatypes.c index b765ec8..044afae 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -31,11 +31,6 @@ #define VIR_FROM_THIS VIR_FROM_NONE -#define virLibConnError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - - virClassPtr virConnectClass; virClassPtr virConnectCloseCallbackDataClass; virClassPtr virDomainClass; @@ -796,22 +791,19 @@ virGetDomainSnapshot(virDomainPtr domain, const char *name) if (virDataTypesInitialize() < 0) return NULL; - if (!VIR_IS_DOMAIN(domain)) { - virLibConnError(VIR_ERR_INVALID_DOMAIN, "%s", _("bad domain")); - return NULL; - } - virCheckNonNullArgReturn(name, NULL); + virCheckDomainGoto(domain, error); + virCheckNonNullArgGoto(name, error); if (!(ret = virObjectNew(virDomainSnapshotClass))) - return NULL; + goto error; if (VIR_STRDUP(ret->name, name) < 0) - goto cleanup; + goto error; ret->domain = virObjectRef(domain); return ret; -cleanup: +error: virObjectUnref(ret); return NULL; } diff --git a/src/datatypes.h b/src/datatypes.h index e3d8da0..eda4b9c 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -64,6 +64,29 @@ extern virClassPtr virStoragePoolClass; (virObjectIsClass((obj), virDomainClass)) # define VIR_IS_CONNECTED_DOMAIN(obj) \ (VIR_IS_DOMAIN(obj) && virObjectIsClass((obj)->conn, virConnectClass)) +# define virCheckDomainReturn(obj, retval) \ + do { \ + virDomainPtr _dom = (obj); \ + if (!virObjectIsClass(_dom, virDomainClass) || \ + !virObjectIsClass(_dom->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_DOM, VIR_ERR_INVALID_DOMAIN, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) +# define virCheckDomainGoto(obj, label) \ + do { \ + virDomainPtr _dom = (obj); \ + if (!virObjectIsClass(_dom, virDomainClass) || \ + !virObjectIsClass(_dom->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_DOM, VIR_ERR_INVALID_DOMAIN, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + goto label; \ + } \ + } while (0) # define VIR_IS_NETWORK(obj) \ (virObjectIsClass((obj), virNetworkClass)) diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index ae8bc88..5de07c3 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -36,10 +36,6 @@ #define VIR_FROM_THIS VIR_FROM_NONE -#define virLibDomainError(domain, error, info) \ - virReportErrorHelper(VIR_FROM_DOM, error, __FILE__, __FUNCTION__, \ - __LINE__, info) - /** * virDomainLxcOpenNamespace: * @domain: a domain object @@ -70,12 +66,7 @@ virDomainLxcOpenNamespace(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; virCheckNonNullArgGoto(fdlist, error); diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 79e8e6b..83d756a 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -30,10 +30,6 @@ #define VIR_FROM_THIS VIR_FROM_NONE -#define virLibDomainError(domain, error, info) \ - virReportErrorHelper(VIR_FROM_DOM, error, __FILE__, __FUNCTION__, \ - __LINE__, info) - /** * virDomainQemuMonitorCommand: * @domain: a domain object @@ -77,12 +73,7 @@ virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; virCheckNonNullArgGoto(result, error); @@ -205,12 +196,7 @@ virDomainQemuAgentCommand(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckDomainReturn(domain, NULL); conn = domain->conn; virCheckReadOnlyGoto(conn->flags, error); diff --git a/src/libvirt.c b/src/libvirt.c index e0b0b32..accbe69 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1908,11 +1908,8 @@ virDomainGetConnect(virDomainPtr dom) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainReturn(dom, NULL); + return dom->conn; } @@ -2236,13 +2233,9 @@ virDomainDestroy(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainDestroy) { @@ -2300,13 +2293,9 @@ virDomainDestroyFlags(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainDestroyFlags) { @@ -2341,11 +2330,8 @@ virDomainFree(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + virObjectUnref(domain); return 0; } @@ -2375,11 +2361,7 @@ virDomainRef(virDomainPtr domain) virResetLastError(); - if ((!VIR_IS_CONNECTED_DOMAIN(domain))) { - virLibConnError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virObjectRef(domain); return 0; @@ -2409,15 +2391,11 @@ virDomainSuspend(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); + if (conn->driver->domainSuspend) { int ret; ret = conn->driver->domainSuspend(domain); @@ -2455,15 +2433,11 @@ virDomainResume(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); + if (conn->driver->domainResume) { int ret; ret = conn->driver->domainResume(domain); @@ -2519,12 +2493,7 @@ virDomainPMSuspendForDuration(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(dom, -1); conn = dom->conn; virCheckReadOnlyGoto(conn->flags, error); @@ -2568,12 +2537,7 @@ virDomainPMWakeup(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(dom, -1); conn = dom->conn; virCheckReadOnlyGoto(conn->flags, error); @@ -2619,13 +2583,10 @@ virDomainSave(virDomainPtr domain, const char *to) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckDomainReturn(domain, -1); conn = domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(to, error); if (conn->driver->domainSave) { @@ -2706,13 +2667,10 @@ virDomainSaveFlags(virDomainPtr domain, const char *to, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckDomainReturn(domain, -1); conn = domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(to, error); if ((flags & VIR_DOMAIN_SAVE_RUNNING) && (flags & VIR_DOMAIN_SAVE_PAUSED)) { @@ -3050,13 +3008,10 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckDomainReturn(domain, -1); conn = domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(to, error); if ((flags & VIR_DUMP_CRASH) && (flags & VIR_DUMP_LIVE)) { @@ -3138,11 +3093,7 @@ virDomainScreenshot(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainReturn(domain, NULL); if (!VIR_IS_STREAM(stream)) { virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); return NULL; @@ -3196,15 +3147,11 @@ virDomainShutdown(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); + if (conn->driver->domainShutdown) { int ret; ret = conn->driver->domainShutdown(domain); @@ -3257,15 +3204,11 @@ virDomainShutdownFlags(virDomainPtr domain, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); + if (conn->driver->domainShutdownFlags) { int ret; ret = conn->driver->domainShutdownFlags(domain, flags); @@ -3319,15 +3262,11 @@ virDomainReboot(virDomainPtr domain, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); + if (conn->driver->domainReboot) { int ret; ret = conn->driver->domainReboot(domain, flags); @@ -3367,15 +3306,11 @@ virDomainReset(virDomainPtr domain, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); + if (conn->driver->domainReset) { int ret; ret = conn->driver->domainReset(domain, flags); @@ -3408,11 +3343,8 @@ virDomainGetName(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainReturn(domain, NULL); + return domain->name; } @@ -3433,11 +3365,7 @@ virDomainGetUUID(virDomainPtr domain, unsigned char *uuid) virResetLastError(); - if (!VIR_IS_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(uuid, error); memcpy(uuid, &domain->uuid[0], VIR_UUID_BUFLEN); @@ -3467,11 +3395,7 @@ virDomainGetUUIDString(virDomainPtr domain, char *buf) virResetLastError(); - if (!VIR_IS_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(buf, error); virUUIDFormat(domain->uuid, buf); @@ -3498,11 +3422,8 @@ virDomainGetID(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return (unsigned int)-1; - } + virCheckDomainReturn(domain, (unsigned int)-1); + return domain->id; } @@ -3525,12 +3446,7 @@ virDomainGetOSType(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckDomainReturn(domain, NULL); conn = domain->conn; if (conn->driver->domainGetOSType) { @@ -3569,12 +3485,7 @@ virDomainGetMaxMemory(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return 0; - } - + virCheckDomainReturn(domain, 0); conn = domain->conn; if (conn->driver->domainGetMaxMemory) { @@ -3623,16 +3534,12 @@ virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); - virCheckNonZeroArgGoto(memory, error); - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); + virCheckNonZeroArgGoto(memory, error); + if (conn->driver->domainSetMaxMemory) { int ret; ret = conn->driver->domainSetMaxMemory(domain, memory); @@ -3673,16 +3580,12 @@ virDomainSetMemory(virDomainPtr domain, unsigned long memory) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); - virCheckNonZeroArgGoto(memory, error); - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); + virCheckNonZeroArgGoto(memory, error); + if (conn->driver->domainSetMemory) { int ret; ret = conn->driver->domainSetMemory(domain, memory); @@ -3734,17 +3637,12 @@ virDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); virCheckNonZeroArgGoto(memory, error); - conn = domain->conn; - if (conn->driver->domainSetMemoryFlags) { int ret; ret = conn->driver->domainSetMemoryFlags(domain, memory, flags); @@ -3793,19 +3691,14 @@ virDomainSetMemoryStatsPeriod(virDomainPtr domain, int period, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); /* This must be positive to set the balloon collection period */ virCheckNonNegativeArgGoto(period, error); - conn = domain->conn; - if (conn->driver->domainSetMemoryStatsPeriod) { int ret; ret = conn->driver->domainSetMemoryStatsPeriod(domain, period, flags); @@ -3890,20 +3783,16 @@ virDomainSetMemoryParameters(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckDomainReturn(domain, -1); + conn = domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckPositiveArgGoto(nparams, error); - if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0) + if (virTypedParameterValidateSet(conn, params, nparams) < 0) goto error; - conn = domain->conn; - if (conn->driver->domainSetMemoryParameters) { int ret; ret = conn->driver->domainSetMemoryParameters(domain, params, nparams, flags); @@ -3967,11 +3856,7 @@ virDomainGetMemoryParameters(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(nparams, error); virCheckNonNegativeArgGoto(*nparams, error); if (*nparams != 0) @@ -4032,11 +3917,7 @@ virDomainSetNumaParameters(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckPositiveArgGoto(nparams, error); @@ -4100,11 +3981,7 @@ virDomainGetNumaParameters(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(nparams, error); virCheckNonNegativeArgGoto(*nparams, error); if (*nparams != 0) @@ -4158,20 +4035,16 @@ virDomainSetBlkioParameters(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckDomainReturn(domain, -1); + conn = domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error); - if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0) + if (virTypedParameterValidateSet(conn, params, nparams) < 0) goto error; - conn = domain->conn; - if (conn->driver->domainSetBlkioParameters) { int ret; ret = conn->driver->domainSetBlkioParameters(domain, params, nparams, flags); @@ -4226,11 +4099,7 @@ virDomainGetBlkioParameters(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(nparams, error); virCheckNonNegativeArgGoto(*nparams, error); if (*nparams != 0) @@ -4287,11 +4156,7 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) memset(info, 0, sizeof(virDomainInfo)); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(info, error); conn = domain->conn; @@ -4338,11 +4203,7 @@ virDomainGetState(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(state, error); conn = domain->conn; @@ -4383,12 +4244,7 @@ virDomainGetControlInfo(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(info, error); conn = domain->conn; @@ -4438,12 +4294,7 @@ virDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckDomainReturn(domain, NULL); conn = domain->conn; if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) { @@ -5389,11 +5240,7 @@ virDomainMigrate(virDomainPtr domain, virResetLastError(); /* First checkout the source */ - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainReturn(domain, NULL); virCheckReadOnlyGoto(domain->conn->flags, error); /* Now checkout the destination */ @@ -5619,11 +5466,7 @@ virDomainMigrate2(virDomainPtr domain, virResetLastError(); /* First checkout the source */ - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainReturn(domain, NULL); virCheckReadOnlyGoto(domain->conn->flags, error); /* Now checkout the destination */ @@ -5800,11 +5643,7 @@ virDomainMigrate3(virDomainPtr domain, virResetLastError(); /* First checkout the source */ - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainReturn(domain, NULL); virCheckReadOnlyGoto(domain->conn->flags, error); /* Now checkout the destination */ @@ -6023,11 +5862,7 @@ virDomainMigrateToURI(virDomainPtr domain, virResetLastError(); /* First checkout the source */ - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonNullArgGoto(duri, error); @@ -6186,11 +6021,7 @@ virDomainMigrateToURI2(virDomainPtr domain, virResetLastError(); /* First checkout the source */ - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckReadOnlyGoto(domain->conn->flags, error); if (flags & VIR_MIGRATE_NON_SHARED_DISK && @@ -6299,11 +6130,7 @@ virDomainMigrateToURI3(virDomainPtr domain, virResetLastError(); /* First checkout the source */ - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckReadOnlyGoto(domain->conn->flags, error); if (flags & VIR_MIGRATE_NON_SHARED_DISK && @@ -6449,14 +6276,10 @@ virDomainMigratePerform(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigratePerform) { int ret; @@ -6667,14 +6490,10 @@ virDomainMigrateBegin3(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainReturn(domain, NULL); conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateBegin3) { char *xml; @@ -6825,14 +6644,10 @@ virDomainMigratePerform3(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigratePerform3) { int ret; @@ -6919,14 +6734,10 @@ virDomainMigrateConfirm3(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateConfirm3) { int ret; @@ -6967,14 +6778,10 @@ virDomainMigrateBegin3Params(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainReturn(domain, NULL); conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateBegin3Params) { char *xml; @@ -7116,14 +6923,10 @@ virDomainMigratePerform3Params(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigratePerform3Params) { int ret; @@ -7209,14 +7012,10 @@ virDomainMigrateConfirm3Params(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateConfirm3Params) { int ret; @@ -7708,11 +7507,7 @@ virDomainGetSchedulerType(virDomainPtr domain, int *nparams) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainReturn(domain, NULL); conn = domain->conn; if (conn->driver->domainGetSchedulerType){ @@ -7760,11 +7555,7 @@ virDomainGetSchedulerParameters(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(params, error); virCheckNonNullArgGoto(nparams, error); @@ -7831,11 +7622,7 @@ virDomainGetSchedulerParametersFlags(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(params, error); virCheckNonNullArgGoto(nparams, error); @@ -7898,21 +7685,16 @@ virDomainSetSchedulerParameters(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error); - if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0) + if (virTypedParameterValidateSet(conn, params, nparams) < 0) goto error; - conn = domain->conn; - if (conn->driver->domainSetSchedulerParameters) { int ret; ret = conn->driver->domainSetSchedulerParameters(domain, params, nparams); @@ -7960,21 +7742,16 @@ virDomainSetSchedulerParametersFlags(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckNonNegativeArgGoto(nparams, error); - if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0) + if (virTypedParameterValidateSet(conn, params, nparams) < 0) goto error; - conn = domain->conn; - if (conn->driver->domainSetSchedulerParametersFlags) { int ret; ret = conn->driver->domainSetSchedulerParametersFlags(domain, @@ -8031,11 +7808,7 @@ virDomainBlockStats(virDomainPtr dom, const char *disk, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); virCheckNonNullArgGoto(disk, error); virCheckNonNullArgGoto(stats, error); if (size > sizeof(stats2)) { @@ -8113,11 +7886,7 @@ virDomainBlockStatsFlags(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); virCheckNonNullArgGoto(disk, error); virCheckNonNullArgGoto(nparams, error); virCheckNonNegativeArgGoto(*nparams, error); @@ -8178,11 +7947,7 @@ virDomainInterfaceStats(virDomainPtr dom, const char *path, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); virCheckNonNullArgGoto(path, error); virCheckNonNullArgGoto(stats, error); if (size > sizeof(stats2)) { @@ -8243,20 +8008,16 @@ virDomainSetInterfaceParameters(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckDomainReturn(domain, -1); + conn = domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(params, error); virCheckPositiveArgGoto(nparams, error); - if (virTypedParameterValidateSet(domain->conn, params, nparams) < 0) + if (virTypedParameterValidateSet(conn, params, nparams) < 0) goto error; - conn = domain->conn; - if (conn->driver->domainSetInterfaceParameters) { int ret; ret = conn->driver->domainSetInterfaceParameters(domain, device, @@ -8314,11 +8075,7 @@ virDomainGetInterfaceParameters(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(nparams, error); virCheckNonNegativeArgGoto(*nparams, error); if (*nparams != 0) @@ -8391,11 +8148,7 @@ virDomainMemoryStats(virDomainPtr dom, virDomainMemoryStatPtr stats, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); if (!stats || nr_stats == 0) return 0; @@ -8479,15 +8232,10 @@ virDomainBlockPeek(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); conn = dom->conn; - virCheckReadOnlyGoto(dom->conn->flags, error); - + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(disk, error); /* Allow size == 0 as an access test. */ @@ -8550,15 +8298,10 @@ virDomainBlockResize(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); conn = dom->conn; - virCheckReadOnlyGoto(dom->conn->flags, error); - + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(disk, error); if (conn->driver->domainBlockResize) { @@ -8625,14 +8368,10 @@ virDomainMemoryPeek(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); conn = dom->conn; - virCheckReadOnlyGoto(dom->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); /* Note on access to physical memory: A VIR_MEMORY_PHYSICAL flag is * a possibility. However it isn't really useful unless the caller @@ -8716,11 +8455,7 @@ virDomainGetBlockInfo(virDomainPtr domain, const char *disk, memset(info, 0, sizeof(virDomainBlockInfo)); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(disk, error); virCheckNonNullArgGoto(info, error); @@ -8816,12 +8551,9 @@ virDomainUndefine(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainUndefine) { @@ -8874,12 +8606,9 @@ virDomainUndefineFlags(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainUndefineFlags) { @@ -9099,12 +8828,9 @@ virDomainCreate(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainCreate) { @@ -9165,12 +8891,9 @@ virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainCreateWithFlags) { @@ -9242,12 +8965,9 @@ virDomainCreateWithFiles(virDomainPtr domain, unsigned int nfiles, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainCreateWithFiles) { @@ -9289,11 +9009,7 @@ virDomainGetAutostart(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(autostart, error); conn = domain->conn; @@ -9334,15 +9050,10 @@ virDomainSetAutostart(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainSetAutostart) { int ret; @@ -9377,15 +9088,11 @@ virDomainInjectNMI(virDomainPtr domain, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); + if (conn->driver->domainInjectNMI) { int ret; ret = conn->driver->domainInjectNMI(domain, flags); @@ -9439,15 +9146,11 @@ virDomainSendKey(virDomainPtr domain, goto error; } - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); + if (conn->driver->domainSendKey) { int ret; ret = conn->driver->domainSendKey(domain, codeset, holdtime, @@ -9510,17 +9213,11 @@ virDomainSendProcessSignal(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; virCheckNonZeroArgGoto(pid_value, error); - - virCheckReadOnlyGoto(domain->conn->flags, error); - - conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainSendProcessSignal) { int ret; @@ -9567,17 +9264,12 @@ virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckDomainReturn(domain, -1); + conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); virCheckNonZeroArgGoto(nvcpus, error); - conn = domain->conn; - if (conn->driver->domainSetVcpus) { int ret; ret = conn->driver->domainSetVcpus(domain, nvcpus); @@ -9640,11 +9332,7 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckReadOnlyGoto(domain->conn->flags, error); if (flags & VIR_DOMAIN_VCPU_GUEST && @@ -9717,11 +9405,7 @@ virDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); /* At most one of these two flags should be set. */ if ((flags & VIR_DOMAIN_AFFECT_LIVE) && @@ -9782,13 +9466,10 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckDomainReturn(domain, -1); + conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(cpumap, error); virCheckPositiveArgGoto(maplen, error); @@ -9797,8 +9478,6 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu, goto error; } - conn = domain->conn; - if (conn->driver->domainPinVcpu) { int ret; ret = conn->driver->domainPinVcpu(domain, vcpu, cpumap, maplen); @@ -9857,16 +9536,12 @@ virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu, VIR_DOMAIN_DEBUG(domain, "vcpu=%u, cpumap=%p, maplen=%d, flags=%x", vcpu, cpumap, maplen, flags); - virResetLastError(); - - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - - virCheckReadOnlyGoto(domain->conn->flags, error); + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(cpumap, error); virCheckPositiveArgGoto(maplen, error); @@ -9875,8 +9550,6 @@ virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu, goto error; } - conn = domain->conn; - if (conn->driver->domainPinVcpuFlags) { int ret; ret = conn->driver->domainPinVcpuFlags(domain, vcpu, cpumap, maplen, flags); @@ -9928,11 +9601,8 @@ virDomainGetVcpuPinInfo(virDomainPtr domain, int ncpumaps, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; virCheckNonNullArgGoto(cpumaps, error); virCheckPositiveArgGoto(ncpumaps, error); @@ -9952,7 +9622,6 @@ virDomainGetVcpuPinInfo(virDomainPtr domain, int ncpumaps, __FUNCTION__); goto error; } - conn = domain->conn; if (conn->driver->domainGetVcpuPinInfo) { int ret; @@ -10014,19 +9683,14 @@ virDomainPinEmulator(virDomainPtr domain, unsigned char *cpumap, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(cpumap, error); virCheckPositiveArgGoto(maplen, error); - conn = domain->conn; - if (conn->driver->domainPinEmulator) { int ret; ret = conn->driver->domainPinEmulator(domain, cpumap, maplen, flags); @@ -10074,11 +9738,7 @@ virDomainGetEmulatorPinInfo(virDomainPtr domain, unsigned char *cpumap, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(cpumap, error); virCheckPositiveArgGoto(maplen, error); @@ -10147,11 +9807,7 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(info, error); virCheckPositiveArgGoto(maxinfo, error); @@ -10208,12 +9864,7 @@ virDomainGetMaxVcpus(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; if (conn->driver->domainGetMaxVcpus) { @@ -10252,16 +9903,11 @@ virDomainGetSecurityLabel(virDomainPtr domain, virSecurityLabelPtr seclabel) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; virCheckNonNullArgGoto(seclabel, error); - conn = domain->conn; - if (conn->driver->domainGetSecurityLabel) { int ret; ret = conn->driver->domainGetSecurityLabel(domain, seclabel); @@ -10300,11 +9946,7 @@ virDomainGetSecurityLabelList(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(seclabels, error); @@ -10371,11 +10013,7 @@ virDomainSetMetadata(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - goto error; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; virCheckReadOnlyGoto(conn->flags, error); @@ -10456,10 +10094,7 @@ virDomainGetMetadata(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - goto error; - } + virCheckDomainReturn(domain, NULL); if ((flags & VIR_DOMAIN_AFFECT_LIVE) && (flags & VIR_DOMAIN_AFFECT_CONFIG)) { @@ -10559,16 +10194,11 @@ virDomainAttachDevice(virDomainPtr domain, const char *xml) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; virCheckNonNullArgGoto(xml, error); - - virCheckReadOnlyGoto(domain->conn->flags, error); - conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainAttachDevice) { int ret; @@ -10620,16 +10250,11 @@ virDomainAttachDeviceFlags(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; virCheckNonNullArgGoto(xml, error); - - virCheckReadOnlyGoto(domain->conn->flags, error); - conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainAttachDeviceFlags) { int ret; @@ -10666,16 +10291,11 @@ virDomainDetachDevice(virDomainPtr domain, const char *xml) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; virCheckNonNullArgGoto(xml, error); - - virCheckReadOnlyGoto(domain->conn->flags, error); - conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainDetachDevice) { int ret; @@ -10743,16 +10363,11 @@ virDomainDetachDeviceFlags(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; virCheckNonNullArgGoto(xml, error); - - virCheckReadOnlyGoto(domain->conn->flags, error); - conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainDetachDeviceFlags) { int ret; @@ -10804,16 +10419,11 @@ virDomainUpdateDeviceFlags(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); + conn = domain->conn; virCheckNonNullArgGoto(xml, error); - - virCheckReadOnlyGoto(domain->conn->flags, error); - conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainUpdateDeviceFlags) { int ret; @@ -17036,11 +16646,8 @@ virDomainIsActive(virDomainPtr dom) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); + if (dom->conn->driver->domainIsActive) { int ret; ret = dom->conn->driver->domainIsActive(dom); @@ -17072,11 +16679,8 @@ virDomainIsPersistent(virDomainPtr dom) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); + if (dom->conn->driver->domainIsPersistent) { int ret; ret = dom->conn->driver->domainIsPersistent(dom); @@ -17107,11 +16711,8 @@ virDomainIsUpdated(virDomainPtr dom) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); + if (dom->conn->driver->domainIsUpdated) { int ret; ret = dom->conn->driver->domainIsUpdated(dom); @@ -18037,11 +17638,7 @@ virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info) memset(info, 0, sizeof(virDomainJobInfo)); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(info, error); conn = domain->conn; @@ -18094,11 +17691,7 @@ virDomainGetJobStats(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(type, error); virCheckNonNullArgGoto(params, error); virCheckNonNullArgGoto(nparams, error); @@ -18140,13 +17733,9 @@ virDomainAbortJob(virDomainPtr domain) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainAbortJob) { @@ -18188,13 +17777,9 @@ virDomainMigrateSetMaxDowntime(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateSetMaxDowntime) { @@ -18232,12 +17817,7 @@ virDomainMigrateGetCompressionCache(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; virCheckNonNullArgGoto(cacheSize, error); @@ -18281,13 +17861,9 @@ virDomainMigrateSetCompressionCache(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateSetCompressionCache) { @@ -18327,13 +17903,9 @@ virDomainMigrateSetMaxSpeed(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateSetMaxSpeed) { @@ -18371,16 +17943,10 @@ virDomainMigrateGetMaxSpeed(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; virCheckNonNullArgGoto(bandwidth, error); - virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainMigrateGetMaxSpeed) { @@ -18443,11 +18009,14 @@ virConnectDomainEventRegisterAny(virConnectPtr conn, virResetLastError(); virCheckConnectReturn(conn, -1); - if (dom != NULL && - !(VIR_IS_CONNECTED_DOMAIN(dom) && dom->conn == conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(conn); - return -1; + if (dom) { + virCheckDomainGoto(dom, error); + if (dom->conn != conn) { + virReportInvalidArg(dom, + _("domain '%s' in %s must match connection"), + dom->name, __FUNCTION__); + goto error; + } } virCheckNonNullArgGoto(cb, error); virCheckNonNegativeArgGoto(eventID, error); @@ -18666,13 +18235,9 @@ virDomainManagedSave(virDomainPtr dom, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(dom, -1); conn = dom->conn; + virCheckReadOnlyGoto(conn->flags, error); if ((flags & VIR_DOMAIN_SAVE_RUNNING) && (flags & VIR_DOMAIN_SAVE_PAUSED)) { @@ -18720,12 +18285,7 @@ virDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(dom, -1); conn = dom->conn; if (conn->driver->domainHasManagedSaveImage) { @@ -18763,13 +18323,9 @@ virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(dom, -1); conn = dom->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainManagedSaveRemove) { @@ -18983,16 +18539,10 @@ virDomainSnapshotCreateXML(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckDomainReturn(domain, NULL); conn = domain->conn; virCheckNonNullArgGoto(xmlDesc, error); - virCheckReadOnlyGoto(conn->flags, error); if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT) && @@ -19136,11 +18686,7 @@ virDomainSnapshotNum(virDomainPtr domain, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(domain, -1); conn = domain->conn; if (conn->driver->domainSnapshotNum) { @@ -19223,12 +18769,7 @@ virDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; virCheckNonNullArgGoto(names, error); @@ -19313,12 +18854,7 @@ virDomainListAllSnapshots(virDomainPtr domain, virDomainSnapshotPtr **snaps, if (snaps) *snaps = NULL; - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; if (conn->driver->domainListAllSnapshots) { @@ -19617,12 +19153,7 @@ virDomainSnapshotLookupByName(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckDomainReturn(domain, NULL); conn = domain->conn; virCheckNonNullArgGoto(name, error); @@ -19660,12 +19191,7 @@ virDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; if (conn->driver->domainHasCurrentSnapshot) { @@ -19703,12 +19229,7 @@ virDomainSnapshotCurrent(virDomainPtr domain, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckDomainReturn(domain, NULL); conn = domain->conn; if (conn->driver->domainSnapshotCurrent) { @@ -20118,13 +19639,9 @@ virDomainOpenConsole(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(dom, -1); conn = dom->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainOpenConsole) { @@ -20178,13 +19695,9 @@ virDomainOpenChannel(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(dom, -1); conn = dom->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->driver->domainOpenChannel) { @@ -20253,15 +19766,10 @@ virDomainBlockJobAbort(virDomainPtr dom, const char *disk, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); conn = dom->conn; - virCheckReadOnlyGoto(dom->conn->flags, error); - + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(disk, error); if (conn->driver->domainBlockJobAbort) { @@ -20311,11 +19819,7 @@ virDomainGetBlockJobInfo(virDomainPtr dom, const char *disk, memset(info, 0, sizeof(*info)); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); conn = dom->conn; virCheckNonNullArgGoto(disk, error); @@ -20367,15 +19871,10 @@ virDomainBlockJobSetSpeed(virDomainPtr dom, const char *disk, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); conn = dom->conn; - virCheckReadOnlyGoto(dom->conn->flags, error); - + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(disk, error); if (conn->driver->domainBlockJobSetSpeed) { @@ -20438,15 +19937,10 @@ virDomainBlockPull(virDomainPtr dom, const char *disk, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); conn = dom->conn; - virCheckReadOnlyGoto(dom->conn->flags, error); - + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(disk, error); if (conn->driver->domainBlockPull) { @@ -20555,15 +20049,10 @@ virDomainBlockRebase(virDomainPtr dom, const char *disk, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); conn = dom->conn; - virCheckReadOnlyGoto(dom->conn->flags, error); - + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(disk, error); if (flags & VIR_DOMAIN_BLOCK_REBASE_COPY) { @@ -20671,15 +20160,10 @@ virDomainBlockCommit(virDomainPtr dom, const char *disk, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); conn = dom->conn; - virCheckReadOnlyGoto(dom->conn->flags, error); - + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(disk, error); if (conn->driver->domainBlockCommit) { @@ -20735,12 +20219,7 @@ virDomainOpenGraphics(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(dom, -1); virCheckNonNegativeArgGoto(fd, error); if (fstat(fd, &sb) < 0) { @@ -21022,14 +20501,10 @@ virDomainSetBlockIoTune(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - - virCheckReadOnlyGoto(dom->conn->flags, error); + virCheckDomainReturn(dom, -1); + conn = dom->conn; + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(disk, error); virCheckPositiveArgGoto(nparams, error); virCheckNonNullArgGoto(params, error); @@ -21037,8 +20512,6 @@ virDomainSetBlockIoTune(virDomainPtr dom, if (virTypedParameterValidateSet(dom->conn, params, nparams) < 0) goto error; - conn = dom->conn; - if (conn->driver->domainSetBlockIoTune) { int ret; ret = conn->driver->domainSetBlockIoTune(dom, disk, params, nparams, flags); @@ -21102,11 +20575,7 @@ virDomainGetBlockIoTune(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); virCheckNonNullArgGoto(nparams, error); virCheckNonNegativeArgGoto(*nparams, error); @@ -21234,13 +20703,9 @@ virDomainGetCPUStats(virDomainPtr domain, params, nparams, start_cpu, ncpus, flags); virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(domain, -1); conn = domain->conn; + /* Special cases: * start_cpu must be non-negative, or else -1 * if start_cpu is -1, ncpus must be 1 @@ -21331,11 +20796,7 @@ virDomainGetDiskErrors(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainReturn(dom, -1); if (maxerrors) virCheckNonNullArgGoto(errors, error); @@ -21380,12 +20841,7 @@ virDomainGetHostname(virDomainPtr domain, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_DOMAIN(domain)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckDomainReturn(domain, NULL); conn = domain->conn; if (conn->driver->domainGetHostname) { @@ -21482,12 +20938,7 @@ virDomainFSTrim(virDomainPtr dom, virResetLastError(); - if (!VIR_IS_DOMAIN(dom)) { - virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainReturn(dom, -1); virCheckReadOnlyGoto(dom->conn->flags, error); if (dom->conn->driver->domainFSTrim) { -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
In datatype.c, virGetDomainSnapshot could result in the message:
error: invalid domain pointer in bad domain
Furthermore, while there are a few functions in libvirt.c that only care about a virDomainPtr without regards to the connection (such as virDomainGetName), most functions also require a valid connection. Yet several functions were blindly derefencing the conn member without checking it for validity first (such as virDomainOpenConsole). Rather than try and correct all usage of VIR_IS_DOMAIN vs. VIR_IS_CONNECTED_DOMAIN, it is easier to just blindly require that a valid domain object always has a valid connection object (which should be true anyways, since every domain object holds a reference to its connection, so the connection will not be closed until all domain objects have also been closed to release their reference).
After this patch, all places that validate a domain consistently report:
error: invalid domain pointer in someFunc
* src/datatypes.h (virCheckDomainReturn, virCheckDomainGoto): New macros. * src/datatypes.c (virGetDomainSnapshot): Use new macro. (virLibConnError): Delete unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- po/POTFILES.in | 1 - src/datatypes.c | 18 +- src/datatypes.h | 23 ++ src/libvirt-lxc.c | 11 +- src/libvirt-qemu.c | 18 +- src/libvirt.c | 1055 +++++++++++++--------------------------------------- 6 files changed, 284 insertions(+), 842 deletions(-)
ACK I was going to point out a couple patches ago about the usage of domain->conn->flags in a call followed by a conn = domain->conn and then usage of conn-> afterwards, but figured it'd be cleared up soon enough... It was! :-) John

On 01/02/2014 04:47 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
In datatype.c, virGetDomainSnapshot could result in the message:
error: invalid domain pointer in bad domain
Furthermore, while there are a few functions in libvirt.c that only care about a virDomainPtr without regards to the connection (such as virDomainGetName), most functions also require a valid connection. Yet several functions were blindly derefencing the
I'll fix that typo while at it.
After this patch, all places that validate a domain consistently report:
error: invalid domain pointer in someFunc
* src/datatypes.h (virCheckDomainReturn, virCheckDomainGoto): New macros. * src/datatypes.c (virGetDomainSnapshot): Use new macro. (virLibConnError): Delete unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- po/POTFILES.in | 1 - src/datatypes.c | 18 +- src/datatypes.h | 23 ++ src/libvirt-lxc.c | 11 +- src/libvirt-qemu.c | 18 +- src/libvirt.c | 1055 +++++++++++++--------------------------------------- 6 files changed, 284 insertions(+), 842 deletions(-)
ACK
I was going to point out a couple patches ago about the usage of domain->conn->flags in a call followed by a conn = domain->conn and then usage of conn-> afterwards, but figured it'd be cleared up soon enough... It was! :-)
Now pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Cleanup after the previous patch. In particular, note that xenDomainUsedCpus can only be reached from xenUnifiedDomainGetXMLDesc, which in turn is only reached from public API that already validated the domain. * src/xen/xen_driver.c (xenDomainUsedCpus): Drop redundant check. * src/datatypes.h (VIR_IS_DOMAIN, VIR_IS_CONNECTED_DOMAIN): Delete, and inline into all callers, since no other file uses it any more. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 8 ++------ src/xen/xen_driver.c | 3 --- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index eda4b9c..ca400ec 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -60,10 +60,6 @@ extern virClassPtr virStoragePoolClass; } \ } while (0) -# define VIR_IS_DOMAIN(obj) \ - (virObjectIsClass((obj), virDomainClass)) -# define VIR_IS_CONNECTED_DOMAIN(obj) \ - (VIR_IS_DOMAIN(obj) && virObjectIsClass((obj)->conn, virConnectClass)) # define virCheckDomainReturn(obj, retval) \ do { \ virDomainPtr _dom = (obj); \ @@ -131,7 +127,7 @@ extern virClassPtr virStoragePoolClass; # define VIR_IS_SNAPSHOT(obj) \ (virObjectIsClass((obj), virDomainSnapshotClass)) # define VIR_IS_DOMAIN_SNAPSHOT(obj) \ - (VIR_IS_SNAPSHOT(obj) && VIR_IS_DOMAIN((obj)->domain)) + (VIR_IS_SNAPSHOT(obj) && virObjectIsClass((obj)->domain, virDomainClass)) /* Helper macros to implement VIR_DOMAIN_DEBUG using just C99. This @@ -169,7 +165,7 @@ extern virClassPtr virStoragePoolClass; char _uuidstr[VIR_UUID_STRING_BUFLEN]; \ const char *_domname = NULL; \ \ - if (!VIR_IS_DOMAIN(dom)) { \ + if (!virObjectIsClass(dom, virDomainClass)) { \ memset(_uuidstr, 0, sizeof(_uuidstr)); \ } else { \ virUUIDFormat((dom)->uuid, _uuidstr); \ diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 07f1ec0..212603a 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -203,9 +203,6 @@ xenDomainUsedCpus(virDomainPtr dom, virDomainDefPtr def) virNodeInfo nodeinfo; xenUnifiedPrivatePtr priv; - if (!VIR_IS_CONNECTED_DOMAIN(dom)) - return NULL; - priv = dom->conn->privateData; if (priv->nbNodeCpus <= 0) -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
Cleanup after the previous patch. In particular, note that xenDomainUsedCpus can only be reached from xenUnifiedDomainGetXMLDesc, which in turn is only reached from public API that already validated the domain.
* src/xen/xen_driver.c (xenDomainUsedCpus): Drop redundant check. * src/datatypes.h (VIR_IS_DOMAIN, VIR_IS_CONNECTED_DOMAIN): Delete, and inline into all callers, since no other file uses it any more.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 8 ++------ src/xen/xen_driver.c | 3 --- 2 files changed, 2 insertions(+), 9 deletions(-)
ACK John

On 01/02/2014 04:50 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
Cleanup after the previous patch. In particular, note that xenDomainUsedCpus can only be reached from xenUnifiedDomainGetXMLDesc, which in turn is only reached from public API that already validated the domain.
* src/xen/xen_driver.c (xenDomainUsedCpus): Drop redundant check. * src/datatypes.h (VIR_IS_DOMAIN, VIR_IS_CONNECTED_DOMAIN): Delete, and inline into all callers, since no other file uses it any more.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 8 ++------ src/xen/xen_driver.c | 3 --- 2 files changed, 2 insertions(+), 9 deletions(-)
ACK
Pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

When checking for a valid network, we weren't consistent on whether we reported an invalid network or a connection. Similar to previous patches, use a common macro to make it nicer. * src/datatypes.h (virCheckNetworkReturn, virCheckNetworkGoto): New macros. (VIR_IS_NETWORK, VIR_IS_CONNECTED_NETWORK): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibNetworkError): Drop unused macro. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 29 +++++++++++-- src/libvirt.c | 131 ++++++++++++++++---------------------------------------- 2 files changed, 61 insertions(+), 99 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index ca400ec..9c40f89 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -84,10 +84,31 @@ extern virClassPtr virStoragePoolClass; } \ } while (0) -# define VIR_IS_NETWORK(obj) \ - (virObjectIsClass((obj), virNetworkClass)) -# define VIR_IS_CONNECTED_NETWORK(obj) \ - (VIR_IS_NETWORK(obj) && virObjectIsClass((obj)->conn, virConnectClass)) +# define virCheckNetworkReturn(obj, retval) \ + do { \ + virNetworkPtr _net = (obj); \ + if (!virObjectIsClass(_net, virNetworkClass) || \ + !virObjectIsClass(_net->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_NETWORK, \ + VIR_ERR_INVALID_NETWORK, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) +# define virCheckNetworkGoto(obj, label) \ + do { \ + virNetworkPtr _net = (obj); \ + if (!virObjectIsClass(_net, virNetworkClass) || \ + !virObjectIsClass(_net->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_NETWORK, \ + VIR_ERR_INVALID_NETWORK, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + goto label; \ + } \ + } while (0) # define VIR_IS_INTERFACE(obj) \ (virObjectIsClass((obj), virInterfaceClass)) diff --git a/src/libvirt.c b/src/libvirt.c index accbe69..8fca384 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -518,9 +518,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, #define virLibDomainError(code, ...) \ virReportErrorHelper(VIR_FROM_DOM, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) -#define virLibNetworkError(code, ...) \ - virReportErrorHelper(VIR_FROM_NETWORK, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) #define virLibStoragePoolError(code, ...) \ virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) @@ -10509,11 +10506,8 @@ virNetworkGetConnect(virNetworkPtr net) virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(net)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckNetworkReturn(net, NULL); + return net->conn; } @@ -10934,12 +10928,9 @@ virNetworkUndefine(virNetworkPtr network) virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNetworkReturn(network, -1); conn = network->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->networkDriver && conn->networkDriver->networkUndefine) { @@ -10991,14 +10982,10 @@ virNetworkUpdate(virNetworkPtr network, virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNetworkReturn(network, -1); conn = network->conn; - virCheckReadOnlyGoto(conn->flags, error); + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(xml, error); if (conn->networkDriver && conn->networkDriver->networkUpdate) { @@ -11035,12 +11022,9 @@ virNetworkCreate(virNetworkPtr network) virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNetworkReturn(network, -1); conn = network->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->networkDriver && conn->networkDriver->networkCreate) { @@ -11078,13 +11062,9 @@ virNetworkDestroy(virNetworkPtr network) virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckNetworkReturn(network, -1); conn = network->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->networkDriver && conn->networkDriver->networkDestroy) { @@ -11119,11 +11099,8 @@ virNetworkFree(virNetworkPtr network) virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNetworkReturn(network, -1); + virObjectUnref(network); return 0; } @@ -11154,11 +11131,8 @@ virNetworkRef(virNetworkPtr network) virResetLastError(); - if ((!VIR_IS_CONNECTED_NETWORK(network))) { - virLibConnError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNetworkReturn(network, -1); + virObjectRef(network); return 0; } @@ -11180,11 +11154,8 @@ virNetworkGetName(virNetworkPtr network) virResetLastError(); - if (!VIR_IS_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckNetworkReturn(network, NULL); + return network->name; } @@ -11205,11 +11176,7 @@ virNetworkGetUUID(virNetworkPtr network, unsigned char *uuid) virResetLastError(); - if (!VIR_IS_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNetworkReturn(network, -1); virCheckNonNullArgGoto(uuid, error); memcpy(uuid, &network->uuid[0], VIR_UUID_BUFLEN); @@ -11239,11 +11206,7 @@ virNetworkGetUUIDString(virNetworkPtr network, char *buf) virResetLastError(); - if (!VIR_IS_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNetworkReturn(network, -1); virCheckNonNullArgGoto(buf, error); virUUIDFormat(network->uuid, buf); @@ -11279,12 +11242,7 @@ virNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckNetworkReturn(network, NULL); conn = network->conn; if (conn->networkDriver && conn->networkDriver->networkGetXMLDesc) { @@ -11321,12 +11279,7 @@ virNetworkGetBridgeName(virNetworkPtr network) virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckNetworkReturn(network, NULL); conn = network->conn; if (conn->networkDriver && conn->networkDriver->networkGetBridgeName) { @@ -11365,11 +11318,7 @@ virNetworkGetAutostart(virNetworkPtr network, virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNetworkReturn(network, -1); virCheckNonNullArgGoto(autostart, error); conn = network->conn; @@ -11409,16 +11358,11 @@ virNetworkSetAutostart(virNetworkPtr network, virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(network)) { - virLibNetworkError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - - virCheckReadOnlyGoto(network->conn->flags, error); - + virCheckNetworkReturn(network, -1); conn = network->conn; + virCheckReadOnlyGoto(conn->flags, error); + if (conn->networkDriver && conn->networkDriver->networkSetAutostart) { int ret; ret = conn->networkDriver->networkSetAutostart(network, autostart); @@ -16743,11 +16687,8 @@ virNetworkIsActive(virNetworkPtr net) virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(net)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNetworkReturn(net, -1); + if (net->conn->networkDriver->networkIsActive) { int ret; ret = net->conn->networkDriver->networkIsActive(net); @@ -16779,11 +16720,8 @@ virNetworkIsPersistent(virNetworkPtr net) virResetLastError(); - if (!VIR_IS_CONNECTED_NETWORK(net)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNetworkReturn(net, -1); + if (net->conn->networkDriver->networkIsPersistent) { int ret; ret = net->conn->networkDriver->networkIsPersistent(net); @@ -18125,11 +18063,14 @@ virConnectNetworkEventRegisterAny(virConnectPtr conn, virResetLastError(); virCheckConnectReturn(conn, -1); - if (net != NULL && - !(VIR_IS_CONNECTED_NETWORK(net) && net->conn == conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(conn); - return -1; + if (net) { + virCheckNetworkGoto(net, error); + if (net->conn != conn) { + virReportInvalidArg(net, + _("network '%s' in %s must match connection"), + net->name, __FUNCTION__); + goto error; + } } virCheckNonNullArgGoto(cb, error); virCheckNonNegativeArgGoto(eventID, error); -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
When checking for a valid network, we weren't consistent on whether we reported an invalid network or a connection. Similar to previous patches, use a common macro to make it nicer.
* src/datatypes.h (virCheckNetworkReturn, virCheckNetworkGoto): New macros. (VIR_IS_NETWORK, VIR_IS_CONNECTED_NETWORK): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibNetworkError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 29 +++++++++++-- src/libvirt.c | 131 ++++++++++++++++---------------------------------------- 2 files changed, 61 insertions(+), 99 deletions(-)
Just making sure it's now expected that virNetworkGetName(), virNetworkGetUUID(), and virNetworkGetUUIDString() will now have to have a connected network just like the new requirement for the various domain API's that previously just cared about a domain regardless of connection. ACK for the mechanical parts... John

On 01/02/2014 05:17 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
When checking for a valid network, we weren't consistent on whether we reported an invalid network or a connection. Similar to previous patches, use a common macro to make it nicer.
* src/datatypes.h (virCheckNetworkReturn, virCheckNetworkGoto): New macros. (VIR_IS_NETWORK, VIR_IS_CONNECTED_NETWORK): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibNetworkError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 29 +++++++++++-- src/libvirt.c | 131 ++++++++++++++++---------------------------------------- 2 files changed, 61 insertions(+), 99 deletions(-)
Just making sure it's now expected that virNetworkGetName(), virNetworkGetUUID(), and virNetworkGetUUIDString() will now have to have a connected network just like the new requirement for the various domain API's that previously just cared about a domain regardless of connection.
A "connected network" is a network that points to a valid virConnectPtr. But based on the way we do reference counting, this should ALWAYS be the case for a valid network. This is the same intentional change as was made for domains in commit 6e130dd. I'll tweak the commit message to make the justification stronger.
ACK for the mechanical parts...
Even though it is now after freeze, this was reviewed before freeze and I think it's better to have the whole series in the release rather than half-and-half. So I'll keep plowing through your review comments, and in particular, I have now pushed this patch. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

When checking for a valid interface, we weren't consistent on whether ew reported as VIR_FROM_NONE or VIR_FROM_INTERFACE. Similar to previous patches, use a common macro to make it nicer. For now, we don't need virCheckInterfaceGoto(). * src/datatypes.h (virCheckInterfaceReturn): New macro. (VIR_IS_INTERFACE, VIR_IS_CONNECTED_INTERFACE): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibInterfaceError): Drop unused macro. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 +++++++++---- src/libvirt.c | 74 +++++++++++++++------------------------------------------ 2 files changed, 32 insertions(+), 59 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index 9c40f89..304e9b5 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -110,10 +110,19 @@ extern virClassPtr virStoragePoolClass; } \ } while (0) -# define VIR_IS_INTERFACE(obj) \ - (virObjectIsClass((obj), virInterfaceClass)) -# define VIR_IS_CONNECTED_INTERFACE(obj) \ - (VIR_IS_INTERFACE(obj) && virObjectIsClass((obj)->conn, virConnectClass)) +# define virCheckInterfaceReturn(obj, retval) \ + do { \ + virInterfacePtr _iface = (obj); \ + if (!virObjectIsClass(_iface, virInterfaceClass) || \ + !virObjectIsClass(_iface->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_INTERFACE, \ + VIR_ERR_INVALID_INTERFACE, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) # define VIR_IS_STORAGE_POOL(obj) \ (virObjectIsClass((obj), virStoragePoolClass)) diff --git a/src/libvirt.c b/src/libvirt.c index 8fca384..55c35d5 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -524,9 +524,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, #define virLibStorageVolError(code, ...) \ virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) -#define virLibInterfaceError(code, ...) \ - virReportErrorHelper(VIR_FROM_INTERFACE, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) #define virLibNodeDeviceError(code, ...) \ virReportErrorHelper(VIR_FROM_NODEDEV, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) @@ -11400,11 +11397,8 @@ virInterfaceGetConnect(virInterfacePtr iface) virResetLastError(); - if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckInterfaceReturn(iface, NULL); + return iface->conn; } @@ -11711,11 +11705,8 @@ virInterfaceGetName(virInterfacePtr iface) virResetLastError(); - if (!VIR_IS_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckInterfaceReturn(iface, NULL); + return iface->name; } @@ -11738,11 +11729,8 @@ virInterfaceGetMACString(virInterfacePtr iface) virResetLastError(); - if (!VIR_IS_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckInterfaceReturn(iface, NULL); + return iface->mac; } @@ -11773,12 +11761,7 @@ virInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckInterfaceReturn(iface, NULL); conn = iface->conn; if (conn->interfaceDriver && conn->interfaceDriver->interfaceGetXMLDesc) { @@ -11871,12 +11854,9 @@ virInterfaceUndefine(virInterfacePtr iface) virResetLastError(); - if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckInterfaceReturn(iface, -1); conn = iface->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceUndefine) { @@ -11917,12 +11897,9 @@ virInterfaceCreate(virInterfacePtr iface, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckInterfaceReturn(iface, -1); conn = iface->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceCreate) { @@ -11967,13 +11944,9 @@ virInterfaceDestroy(virInterfacePtr iface, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckInterfaceReturn(iface, -1); conn = iface->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->interfaceDriver && conn->interfaceDriver->interfaceDestroy) { @@ -12016,11 +11989,8 @@ virInterfaceRef(virInterfacePtr iface) virResetLastError(); - if ((!VIR_IS_CONNECTED_INTERFACE(iface))) { - virLibConnError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckInterfaceReturn(iface, -1); + virObjectRef(iface); return 0; } @@ -12042,11 +12012,8 @@ virInterfaceFree(virInterfacePtr iface) virResetLastError(); - if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckInterfaceReturn(iface, -1); + virObjectUnref(iface); return 0; } @@ -17325,11 +17292,8 @@ virInterfaceIsActive(virInterfacePtr iface) virResetLastError(); - if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckInterfaceReturn(iface, -1); + if (iface->conn->interfaceDriver->interfaceIsActive) { int ret; ret = iface->conn->interfaceDriver->interfaceIsActive(iface); -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
When checking for a valid interface, we weren't consistent on whether ew reported as VIR_FROM_NONE or VIR_FROM_INTERFACE. Similar to previous patches, use a common macro to make it nicer. For now, we don't need virCheckInterfaceGoto().
* src/datatypes.h (virCheckInterfaceReturn): New macro. (VIR_IS_INTERFACE, VIR_IS_CONNECTED_INTERFACE): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibInterfaceError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 +++++++++---- src/libvirt.c | 74 +++++++++++++++------------------------------------------ 2 files changed, 32 insertions(+), 59 deletions(-)
Same concern as Networks - the virInterfaceGetName() and virInterfaceGetMACString() will require a connection... ACK John
diff --git a/src/datatypes.h b/src/datatypes.h index 9c40f89..304e9b5 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -110,10 +110,19 @@ extern virClassPtr virStoragePoolClass; } \ } while (0)
-# define VIR_IS_INTERFACE(obj) \ - (virObjectIsClass((obj), virInterfaceClass)) -# define VIR_IS_CONNECTED_INTERFACE(obj) \ - (VIR_IS_INTERFACE(obj) && virObjectIsClass((obj)->conn, virConnectClass)) +# define virCheckInterfaceReturn(obj, retval) \ + do { \ + virInterfacePtr _iface = (obj); \ + if (!virObjectIsClass(_iface, virInterfaceClass) || \ + !virObjectIsClass(_iface->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_INTERFACE, \ + VIR_ERR_INVALID_INTERFACE, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0)
# define VIR_IS_STORAGE_POOL(obj) \ (virObjectIsClass((obj), virStoragePoolClass)) diff --git a/src/libvirt.c b/src/libvirt.c index 8fca384..55c35d5 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -524,9 +524,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, #define virLibStorageVolError(code, ...) \ virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) -#define virLibInterfaceError(code, ...) \ - virReportErrorHelper(VIR_FROM_INTERFACE, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) #define virLibNodeDeviceError(code, ...) \ virReportErrorHelper(VIR_FROM_NODEDEV, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) @@ -11400,11 +11397,8 @@ virInterfaceGetConnect(virInterfacePtr iface)
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckInterfaceReturn(iface, NULL); + return iface->conn; }
@@ -11711,11 +11705,8 @@ virInterfaceGetName(virInterfacePtr iface)
virResetLastError();
- if (!VIR_IS_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckInterfaceReturn(iface, NULL); + return iface->name; }
@@ -11738,11 +11729,8 @@ virInterfaceGetMACString(virInterfacePtr iface)
virResetLastError();
- if (!VIR_IS_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckInterfaceReturn(iface, NULL); + return iface->mac; }
@@ -11773,12 +11761,7 @@ virInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags)
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckInterfaceReturn(iface, NULL); conn = iface->conn;
if (conn->interfaceDriver && conn->interfaceDriver->interfaceGetXMLDesc) { @@ -11871,12 +11854,9 @@ virInterfaceUndefine(virInterfacePtr iface)
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckInterfaceReturn(iface, -1); conn = iface->conn; + virCheckReadOnlyGoto(conn->flags, error);
if (conn->interfaceDriver && conn->interfaceDriver->interfaceUndefine) { @@ -11917,12 +11897,9 @@ virInterfaceCreate(virInterfacePtr iface, unsigned int flags)
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckInterfaceReturn(iface, -1); conn = iface->conn; + virCheckReadOnlyGoto(conn->flags, error);
if (conn->interfaceDriver && conn->interfaceDriver->interfaceCreate) { @@ -11967,13 +11944,9 @@ virInterfaceDestroy(virInterfacePtr iface, unsigned int flags)
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckInterfaceReturn(iface, -1); conn = iface->conn; + virCheckReadOnlyGoto(conn->flags, error);
if (conn->interfaceDriver && conn->interfaceDriver->interfaceDestroy) { @@ -12016,11 +11989,8 @@ virInterfaceRef(virInterfacePtr iface)
virResetLastError();
- if ((!VIR_IS_CONNECTED_INTERFACE(iface))) { - virLibConnError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckInterfaceReturn(iface, -1); + virObjectRef(iface); return 0; } @@ -12042,11 +12012,8 @@ virInterfaceFree(virInterfacePtr iface)
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibInterfaceError(VIR_ERR_INVALID_INTERFACE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckInterfaceReturn(iface, -1); + virObjectUnref(iface); return 0; } @@ -17325,11 +17292,8 @@ virInterfaceIsActive(virInterfacePtr iface)
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(iface)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckInterfaceReturn(iface, -1); + if (iface->conn->interfaceDriver->interfaceIsActive) { int ret; ret = iface->conn->interfaceDriver->interfaceIsActive(iface);

On 01/02/2014 05:19 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
When checking for a valid interface, we weren't consistent on whether ew reported as VIR_FROM_NONE or VIR_FROM_INTERFACE.
s/ew/we/
Similar to previous patches, use a common macro to make it nicer. For now, we don't need virCheckInterfaceGoto().
* src/datatypes.h (virCheckInterfaceReturn): New macro. (VIR_IS_INTERFACE, VIR_IS_CONNECTED_INTERFACE): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibInterfaceError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 +++++++++---- src/libvirt.c | 74 +++++++++++++++------------------------------------------ 2 files changed, 32 insertions(+), 59 deletions(-)
Same concern as Networks - the virInterfaceGetName() and virInterfaceGetMACString() will require a connection...
And same response - I touched up the commit message to explain it better.
ACK
Pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

virStoragePoolBuild reported an invalid pool as if it were an invalid network. Likewise, we weren't consistent on whether to use VIR_FROM_NONE or VIR_FROM_STORAGE. Similar to previous patches, use a common macro to make it nicer. For now, we don't need virCheckStoragePoolGoto(). * src/datatypes.h (virCheckStoragePoolReturn): New macro. (VIR_IS_STORAGE_POOL, VIR_IS_CONNECTED_STORAGE_POOL): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibStoragePoolError): Drop unused macro. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 ++++-- src/libvirt.c | 172 +++++++++++++------------------------------------------- 2 files changed, 51 insertions(+), 138 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index 304e9b5..0be271d 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -124,10 +124,19 @@ extern virClassPtr virStoragePoolClass; } \ } while (0) -# define VIR_IS_STORAGE_POOL(obj) \ - (virObjectIsClass((obj), virStoragePoolClass)) -# define VIR_IS_CONNECTED_STORAGE_POOL(obj) \ - (VIR_IS_STORAGE_POOL(obj) && virObjectIsClass((obj)->conn, virConnectClass)) +# define virCheckStoragePoolReturn(obj, retval) \ + do { \ + virStoragePoolPtr _pool = (obj); \ + if (!virObjectIsClass(_pool, virStoragePoolClass) || \ + !virObjectIsClass(_pool->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_STORAGE, \ + VIR_ERR_INVALID_STORAGE_POOL, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) # define VIR_IS_STORAGE_VOL(obj) \ (virObjectIsClass((obj), virStorageVolClass)) diff --git a/src/libvirt.c b/src/libvirt.c index 55c35d5..65dc364 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -518,9 +518,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, #define virLibDomainError(code, ...) \ virReportErrorHelper(VIR_FROM_DOM, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) -#define virLibStoragePoolError(code, ...) \ - virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) #define virLibStorageVolError(code, ...) \ virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) @@ -12164,11 +12161,8 @@ virStoragePoolGetConnect(virStoragePoolPtr pool) virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckStoragePoolReturn(pool, NULL); + return pool->conn; } @@ -12713,12 +12707,9 @@ virStoragePoolBuild(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); conn = pool->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolBuild) { @@ -12753,12 +12744,9 @@ virStoragePoolUndefine(virStoragePoolPtr pool) virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_NETWORK, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); conn = pool->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolUndefine) { @@ -12795,12 +12783,9 @@ virStoragePoolCreate(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); conn = pool->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolCreate) { @@ -12839,13 +12824,9 @@ virStoragePoolDestroy(virStoragePoolPtr pool) virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStoragePoolReturn(pool, -1); conn = pool->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolDestroy) { @@ -12884,13 +12865,9 @@ virStoragePoolDelete(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStoragePoolReturn(pool, -1); conn = pool->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolDelete) { @@ -12925,11 +12902,8 @@ virStoragePoolFree(virStoragePoolPtr pool) virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); + virObjectUnref(pool); return 0; @@ -12960,11 +12934,8 @@ virStoragePoolRef(virStoragePoolPtr pool) virResetLastError(); - if ((!VIR_IS_CONNECTED_STORAGE_POOL(pool))) { - virLibConnError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); + virObjectRef(pool); return 0; } @@ -12990,13 +12961,9 @@ virStoragePoolRefresh(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStoragePoolReturn(pool, -1); conn = pool->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storagePoolRefresh) { @@ -13030,11 +12997,8 @@ virStoragePoolGetName(virStoragePoolPtr pool) virResetLastError(); - if (!VIR_IS_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckStoragePoolReturn(pool, NULL); + return pool->name; } @@ -13056,11 +13020,7 @@ virStoragePoolGetUUID(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); virCheckNonNullArgGoto(uuid, error); memcpy(uuid, &pool->uuid[0], VIR_UUID_BUFLEN); @@ -13090,11 +13050,7 @@ virStoragePoolGetUUIDString(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); virCheckNonNullArgGoto(buf, error); virUUIDFormat(pool->uuid, buf); @@ -13127,11 +13083,7 @@ virStoragePoolGetInfo(virStoragePoolPtr pool, memset(info, 0, sizeof(virStoragePoolInfo)); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); virCheckNonNullArgGoto(info, error); conn = pool->conn; @@ -13172,12 +13124,7 @@ virStoragePoolGetXMLDesc(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckStoragePoolReturn(pool, NULL); conn = pool->conn; if (conn->storageDriver && conn->storageDriver->storagePoolGetXMLDesc) { @@ -13215,11 +13162,7 @@ virStoragePoolGetAutostart(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); virCheckNonNullArgGoto(autostart, error); conn = pool->conn; @@ -13258,16 +13201,11 @@ virStoragePoolSetAutostart(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibStoragePoolError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - - virCheckReadOnlyGoto(pool->conn->flags, error); - + virCheckStoragePoolReturn(pool, -1); conn = pool->conn; + virCheckReadOnlyGoto(conn->flags, error); + if (conn->storageDriver && conn->storageDriver->storagePoolSetAutostart) { int ret; ret = conn->storageDriver->storagePoolSetAutostart(pool, autostart); @@ -13311,11 +13249,7 @@ virStoragePoolListAllVolumes(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_STORAGE_POOL(pool)) { - virLibConnError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); if (pool->conn->storageDriver && pool->conn->storageDriver->storagePoolListAllVolumes) { @@ -13349,11 +13283,7 @@ virStoragePoolNumOfVolumes(virStoragePoolPtr pool) virResetLastError(); - if (!VIR_IS_STORAGE_POOL(pool)) { - virLibConnError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); if (pool->conn->storageDriver && pool->conn->storageDriver->storagePoolNumOfVolumes) { int ret; @@ -13393,12 +13323,7 @@ virStoragePoolListVolumes(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_STORAGE_POOL(pool)) { - virLibConnError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStoragePoolReturn(pool, -1); virCheckNonNullArgGoto(names, error); virCheckNonNegativeArgGoto(maxnames, error); @@ -13466,12 +13391,7 @@ virStorageVolLookupByName(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_STORAGE_POOL(pool)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckStoragePoolReturn(pool, NULL); virCheckNonNullArgGoto(name, error); if (pool->conn->storageDriver && pool->conn->storageDriver->storageVolLookupByName) { @@ -13641,14 +13561,8 @@ virStorageVolCreateXML(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_STORAGE_POOL(pool)) { - virLibConnError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckStoragePoolReturn(pool, NULL); virCheckNonNullArgGoto(xmlDesc, error); - virCheckReadOnlyGoto(pool->conn->flags, error); if (pool->conn->storageDriver && pool->conn->storageDriver->storageVolCreateXML) { @@ -13697,11 +13611,7 @@ virStorageVolCreateXMLFrom(virStoragePoolPtr pool, virResetLastError(); - if (!VIR_IS_STORAGE_POOL(pool)) { - virLibConnError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckStoragePoolReturn(pool, NULL); if (!VIR_IS_STORAGE_VOL(clonevol)) { virLibConnError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); @@ -16719,11 +16629,8 @@ virStoragePoolIsActive(virStoragePoolPtr pool) virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); + if (pool->conn->storageDriver->storagePoolIsActive) { int ret; ret = pool->conn->storageDriver->storagePoolIsActive(pool); @@ -16755,11 +16662,8 @@ virStoragePoolIsPersistent(virStoragePoolPtr pool) virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStoragePoolReturn(pool, -1); + if (pool->conn->storageDriver->storagePoolIsPersistent) { int ret; ret = pool->conn->storageDriver->storagePoolIsPersistent(pool); -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
virStoragePoolBuild reported an invalid pool as if it were an invalid network. Likewise, we weren't consistent on whether to use VIR_FROM_NONE or VIR_FROM_STORAGE. Similar to previous patches, use a common macro to make it nicer. For now, we don't need virCheckStoragePoolGoto().
* src/datatypes.h (virCheckStoragePoolReturn): New macro. (VIR_IS_STORAGE_POOL, VIR_IS_CONNECTED_STORAGE_POOL): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibStoragePoolError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 ++++-- src/libvirt.c | 172 +++++++++++++------------------------------------------- 2 files changed, 51 insertions(+), 138 deletions(-)
Same as previous w/r/t connection required for GetName, GetUUID, and GetUUIDString ACK John

On 01/02/2014 05:23 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
virStoragePoolBuild reported an invalid pool as if it were an invalid network. Likewise, we weren't consistent on whether to use VIR_FROM_NONE or VIR_FROM_STORAGE. Similar to previous patches, use a common macro to make it nicer. For now, we don't need virCheckStoragePoolGoto().
* src/datatypes.h (virCheckStoragePoolReturn): New macro. (VIR_IS_STORAGE_POOL, VIR_IS_CONNECTED_STORAGE_POOL): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibStoragePoolError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 ++++-- src/libvirt.c | 172 +++++++++++++------------------------------------------- 2 files changed, 51 insertions(+), 138 deletions(-)
Same as previous w/r/t connection required for GetName, GetUUID, and GetUUIDString
And same answer, fixed by improving the commit message.
ACK
Pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

For storage volume validation, we weren't consistent on whether to use VIR_FROM_NONE or VIR_FROM_STORAGE. Similar to previous patches, use a common macro to make it nicer. virStorageVolCreateXMLFrom allows cross-connection cloning, where the error is reported against the connection of the destination pool. * src/datatypes.h (virCheckStorageVolReturn) (virCheckStorageVolGoto): New macros. (VIR_IS_STORAGE_VOL, VIR_IS_CONNECTED_STORAGE_VOL): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibStorageVolError): Drop unused macro. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 29 +++++++++++++-- src/libvirt.c | 112 ++++++++++++-------------------------------------------- 2 files changed, 49 insertions(+), 92 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index 0be271d..2f4b894 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -138,10 +138,31 @@ extern virClassPtr virStoragePoolClass; } \ } while (0) -# define VIR_IS_STORAGE_VOL(obj) \ - (virObjectIsClass((obj), virStorageVolClass)) -# define VIR_IS_CONNECTED_STORAGE_VOL(obj) \ - (VIR_IS_STORAGE_VOL(obj) && virObjectIsClass((obj)->conn, virConnectClass)) +# define virCheckStorageVolReturn(obj, retval) \ + do { \ + virStorageVolPtr _vol = (obj); \ + if (!virObjectIsClass(_vol, virStorageVolClass) || \ + !virObjectIsClass(_vol->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_STORAGE, \ + VIR_ERR_INVALID_STORAGE_VOL, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) +# define virCheckStorageVolGoto(obj, label) \ + do { \ + virStorageVolPtr _vol = (obj); \ + if (!virObjectIsClass(_vol, virStorageVolClass) || \ + !virObjectIsClass(_vol->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_STORAGE, \ + VIR_ERR_INVALID_STORAGE_VOL, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + goto label; \ + } \ + } while (0) # define VIR_IS_NODE_DEVICE(obj) \ (virObjectIsClass((obj), virNodeDeviceClass)) diff --git a/src/libvirt.c b/src/libvirt.c index 65dc364..47e8bd3 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -518,9 +518,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, #define virLibDomainError(code, ...) \ virReportErrorHelper(VIR_FROM_DOM, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) -#define virLibStorageVolError(code, ...) \ - virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) #define virLibNodeDeviceError(code, ...) \ virReportErrorHelper(VIR_FROM_NODEDEV, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) @@ -12583,11 +12580,7 @@ virStoragePoolLookupByVolume(virStorageVolPtr vol) virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) { - virLibConnError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckStorageVolReturn(vol, NULL); if (vol->conn->storageDriver && vol->conn->storageDriver->storagePoolLookupByVolume) { virStoragePoolPtr ret; @@ -13364,11 +13357,8 @@ virStorageVolGetConnect(virStorageVolPtr vol) virResetLastError(); - if (!VIR_IS_STORAGE_VOL(vol)) { - virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckStorageVolReturn(vol, NULL); + return vol->conn; } @@ -13500,11 +13490,8 @@ virStorageVolGetName(virStorageVolPtr vol) virResetLastError(); - if (!VIR_IS_STORAGE_VOL(vol)) { - virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckStorageVolReturn(vol, NULL); + return vol->name; } @@ -13526,11 +13513,8 @@ virStorageVolGetKey(virStorageVolPtr vol) virResetLastError(); - if (!VIR_IS_STORAGE_VOL(vol)) { - virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckStorageVolReturn(vol, NULL); + return vol->key; } @@ -13612,12 +13596,7 @@ virStorageVolCreateXMLFrom(virStoragePoolPtr pool, virResetLastError(); virCheckStoragePoolReturn(pool, NULL); - - if (!VIR_IS_STORAGE_VOL(clonevol)) { - virLibConnError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - goto error; - } - + virCheckStorageVolGoto(clonevol, error); virCheckNonNullArgGoto(xmlDesc, error); virCheckReadOnlyGoto(pool->conn->flags | clonevol->conn->flags, error); @@ -13671,10 +13650,7 @@ virStorageVolDownload(virStorageVolPtr vol, virResetLastError(); - if (!VIR_IS_STORAGE_VOL(vol)) { - virLibConnError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - return -1; - } + virCheckStorageVolReturn(vol, -1); if (!VIR_IS_STREAM(stream)) { virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); @@ -13738,10 +13714,7 @@ virStorageVolUpload(virStorageVolPtr vol, virResetLastError(); - if (!VIR_IS_STORAGE_VOL(vol)) { - virLibConnError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - return -1; - } + virCheckStorageVolReturn(vol, -1); if (!VIR_IS_STREAM(stream)) { virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); @@ -13789,13 +13762,9 @@ virStorageVolDelete(virStorageVolPtr vol, virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) { - virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStorageVolReturn(vol, -1); conn = vol->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storageVolDelete) { @@ -13832,13 +13801,9 @@ virStorageVolWipe(virStorageVolPtr vol, virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) { - virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStorageVolReturn(vol, -1); conn = vol->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storageVolWipe) { @@ -13879,13 +13844,9 @@ virStorageVolWipePattern(virStorageVolPtr vol, virResetLastError(); - if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) { - virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStorageVolReturn(vol, -1); conn = vol->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->storageDriver && conn->storageDriver->storageVolWipePattern) { @@ -13921,11 +13882,8 @@ virStorageVolFree(virStorageVolPtr vol) virResetLastError(); - if (!VIR_IS_STORAGE_VOL(vol)) { - virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStorageVolReturn(vol, -1); + virObjectUnref(vol); return 0; } @@ -13955,11 +13913,8 @@ virStorageVolRef(virStorageVolPtr vol) virResetLastError(); - if ((!VIR_IS_CONNECTED_STORAGE_VOL(vol))) { - virLibConnError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStorageVolReturn(vol, -1); + virObjectRef(vol); return 0; } @@ -13986,11 +13941,7 @@ virStorageVolGetInfo(virStorageVolPtr vol, memset(info, 0, sizeof(virStorageVolInfo)); - if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) { - virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStorageVolReturn(vol, -1); virCheckNonNullArgGoto(info, error); conn = vol->conn; @@ -14030,12 +13981,7 @@ virStorageVolGetXMLDesc(virStorageVolPtr vol, virResetLastError(); - if (!VIR_IS_STORAGE_VOL(vol)) { - virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckStorageVolReturn(vol, NULL); conn = vol->conn; if (conn->storageDriver && conn->storageDriver->storageVolGetXMLDesc) { @@ -14075,12 +14021,7 @@ virStorageVolGetPath(virStorageVolPtr vol) virResetLastError(); - if (!VIR_IS_STORAGE_VOL(vol)) { - virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckStorageVolReturn(vol, NULL); conn = vol->conn; if (conn->storageDriver && conn->storageDriver->storageVolGetPath) { @@ -14143,12 +14084,7 @@ virStorageVolResize(virStorageVolPtr vol, virResetLastError(); - if (!VIR_IS_STORAGE_VOL(vol)) { - virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStorageVolReturn(vol, -1); conn = vol->conn; virCheckReadOnlyGoto(conn->flags, error); -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
For storage volume validation, we weren't consistent on whether to use VIR_FROM_NONE or VIR_FROM_STORAGE. Similar to previous patches, use a common macro to make it nicer.
virStorageVolCreateXMLFrom allows cross-connection cloning, where the error is reported against the connection of the destination pool.
* src/datatypes.h (virCheckStorageVolReturn) (virCheckStorageVolGoto): New macros. (VIR_IS_STORAGE_VOL, VIR_IS_CONNECTED_STORAGE_VOL): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibStorageVolError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 29 +++++++++++++-- src/libvirt.c | 112 ++++++++++++-------------------------------------------- 2 files changed, 49 insertions(+), 92 deletions(-)
Same as previous w/r/t GetName and GetKey here. ACK John

On 01/02/2014 05:28 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
For storage volume validation, we weren't consistent on whether to use VIR_FROM_NONE or VIR_FROM_STORAGE. Similar to previous patches, use a common macro to make it nicer.
virStorageVolCreateXMLFrom allows cross-connection cloning, where the error is reported against the connection of the destination pool.
* src/datatypes.h (virCheckStorageVolReturn) (virCheckStorageVolGoto): New macros. (VIR_IS_STORAGE_VOL, VIR_IS_CONNECTED_STORAGE_VOL): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibStorageVolError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 29 +++++++++++++-- src/libvirt.c | 112 ++++++++++++-------------------------------------------- 2 files changed, 49 insertions(+), 92 deletions(-)
Same as previous w/r/t GetName and GetKey here.
ACK
Same response; I improved the commit message before pushing. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

While all errors related to invalid node device appeared to be consistent, we might as well continue the trend of using a common macro. For now, we don't need virCheckNodeDeviceGoto(). * src/datatypes.h (virCheckNodeDeviceReturn): New macro. (VIR_IS_NODE_DEVICE, VIR_IS_CONNECTED_NODE_DEVICE): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibNodeDeviceError): Drop unused macro. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 +++++++++--- src/libvirt.c | 83 ++++++++++----------------------------------------------- 2 files changed, 27 insertions(+), 73 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index 2f4b894..8b3b153 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -164,10 +164,19 @@ extern virClassPtr virStoragePoolClass; } \ } while (0) -# define VIR_IS_NODE_DEVICE(obj) \ - (virObjectIsClass((obj), virNodeDeviceClass)) -# define VIR_IS_CONNECTED_NODE_DEVICE(obj) \ - (VIR_IS_NODE_DEVICE(obj) && virObjectIsClass((obj)->conn, virConnectClass)) +# define virCheckNodeDeviceReturn(obj, retval) \ + do { \ + virNodeDevicePtr _node = (obj); \ + if (!virObjectIsClass(_node, virNodeDeviceClass) || \ + !virObjectIsClass(_node->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_NODEDEV, \ + VIR_ERR_INVALID_NODE_DEVICE, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) # define VIR_IS_SECRET(obj) \ (virObjectIsClass((obj), virSecretClass)) diff --git a/src/libvirt.c b/src/libvirt.c index 47e8bd3..6b6e19b 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -518,9 +518,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, #define virLibDomainError(code, ...) \ virReportErrorHelper(VIR_FROM_DOM, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) -#define virLibNodeDeviceError(code, ...) \ - virReportErrorHelper(VIR_FROM_NODEDEV, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) #define virLibSecretError(code, ...) \ virReportErrorHelper(VIR_FROM_SECRET, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) @@ -14364,11 +14361,7 @@ char *virNodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { - virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckNodeDeviceReturn(dev, NULL); if (dev->conn->nodeDeviceDriver && dev->conn->nodeDeviceDriver->nodeDeviceGetXMLDesc) { char *ret; @@ -14400,11 +14393,7 @@ const char *virNodeDeviceGetName(virNodeDevicePtr dev) virResetLastError(); - if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { - virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckNodeDeviceReturn(dev, NULL); return dev->name; } @@ -14425,11 +14414,7 @@ const char *virNodeDeviceGetParent(virNodeDevicePtr dev) virResetLastError(); - if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { - virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckNodeDeviceReturn(dev, NULL); if (!dev->parent) { if (dev->conn->nodeDeviceDriver && dev->conn->nodeDeviceDriver->nodeDeviceGetParent) { @@ -14459,11 +14444,7 @@ virNodeDeviceNumOfCaps(virNodeDevicePtr dev) virResetLastError(); - if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { - virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNodeDeviceReturn(dev, -1); if (dev->conn->nodeDeviceDriver && dev->conn->nodeDeviceDriver->nodeDeviceNumOfCaps) { int ret; @@ -14501,12 +14482,7 @@ virNodeDeviceListCaps(virNodeDevicePtr dev, virResetLastError(); - if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { - virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckNodeDeviceReturn(dev, -1); virCheckNonNullArgGoto(names, error); virCheckNonNegativeArgGoto(maxnames, error); @@ -14542,11 +14518,8 @@ virNodeDeviceFree(virNodeDevicePtr dev) virResetLastError(); - if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { - virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNodeDeviceReturn(dev, -1); + virObjectUnref(dev); return 0; } @@ -14576,11 +14549,8 @@ virNodeDeviceRef(virNodeDevicePtr dev) virResetLastError(); - if ((!VIR_IS_CONNECTED_NODE_DEVICE(dev))) { - virLibConnError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNodeDeviceReturn(dev, -1); + virObjectRef(dev); return 0; } @@ -14617,12 +14587,7 @@ virNodeDeviceDettach(virNodeDevicePtr dev) virResetLastError(); - if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { - virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckNodeDeviceReturn(dev, -1); virCheckReadOnlyGoto(dev->conn->flags, error); if (dev->conn->driver->nodeDeviceDettach) { @@ -14679,12 +14644,7 @@ virNodeDeviceDetachFlags(virNodeDevicePtr dev, virResetLastError(); - if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { - virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckNodeDeviceReturn(dev, -1); virCheckReadOnlyGoto(dev->conn->flags, error); if (dev->conn->driver->nodeDeviceDetachFlags) { @@ -14725,12 +14685,7 @@ virNodeDeviceReAttach(virNodeDevicePtr dev) virResetLastError(); - if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { - virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckNodeDeviceReturn(dev, -1); virCheckReadOnlyGoto(dev->conn->flags, error); if (dev->conn->driver->nodeDeviceReAttach) { @@ -14773,12 +14728,7 @@ virNodeDeviceReset(virNodeDevicePtr dev) virResetLastError(); - if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { - virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckNodeDeviceReturn(dev, -1); virCheckReadOnlyGoto(dev->conn->flags, error); if (dev->conn->driver->nodeDeviceReset) { @@ -14854,12 +14804,7 @@ virNodeDeviceDestroy(virNodeDevicePtr dev) virResetLastError(); - if (!VIR_IS_CONNECTED_NODE_DEVICE(dev)) { - virLibNodeDeviceError(VIR_ERR_INVALID_NODE_DEVICE, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckNodeDeviceReturn(dev, -1); virCheckReadOnlyGoto(dev->conn->flags, error); if (dev->conn->nodeDeviceDriver && -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
While all errors related to invalid node device appeared to be consistent, we might as well continue the trend of using a common macro. For now, we don't need virCheckNodeDeviceGoto().
* src/datatypes.h (virCheckNodeDeviceReturn): New macro. (VIR_IS_NODE_DEVICE, VIR_IS_CONNECTED_NODE_DEVICE): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibNodeDeviceError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 +++++++++--- src/libvirt.c | 83 ++++++++++----------------------------------------------- 2 files changed, 27 insertions(+), 73 deletions(-)
ACK John

On 01/02/2014 05:30 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
While all errors related to invalid node device appeared to be consistent, we might as well continue the trend of using a common macro. For now, we don't need virCheckNodeDeviceGoto().
* src/datatypes.h (virCheckNodeDeviceReturn): New macro. (VIR_IS_NODE_DEVICE, VIR_IS_CONNECTED_NODE_DEVICE): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibNodeDeviceError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 +++++++++--- src/libvirt.c | 83 ++++++++++----------------------------------------------- 2 files changed, 27 insertions(+), 73 deletions(-)
ACK
Pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

While all errors related to invalid secrets appeared to be consistent, we might as well continue the trend of using a common macro. For now, we don't need virCheckSecretGoto(). * src/datatypes.h (virCheckSecretReturn): New macro. (VIR_IS_SECRET, VIR_IS_CONNECTED_SECRET): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibSecretError): Drop unused macro. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 ++++++++++--- src/libvirt.c | 79 +++++++++++++++------------------------------------------ 2 files changed, 33 insertions(+), 63 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index 8b3b153..024a2e3 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -178,10 +178,19 @@ extern virClassPtr virStoragePoolClass; } \ } while (0) -# define VIR_IS_SECRET(obj) \ - (virObjectIsClass((obj), virSecretClass)) -# define VIR_IS_CONNECTED_SECRET(obj) \ - (VIR_IS_SECRET(obj) && virObjectIsClass((obj)->conn, virConnectClass)) +# define virCheckSecretReturn(obj, retval) \ + do { \ + virSecretPtr _secret = (obj); \ + if (!virObjectIsClass(_secret, virSecretClass) || \ + !virObjectIsClass(_secret->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_SECRET, \ + VIR_ERR_INVALID_SECRET, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) # define VIR_IS_STREAM(obj) \ (virObjectIsClass((obj), virStreamClass)) diff --git a/src/libvirt.c b/src/libvirt.c index 6b6e19b..eaa4c89 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -518,9 +518,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, #define virLibDomainError(code, ...) \ virReportErrorHelper(VIR_FROM_DOM, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) -#define virLibSecretError(code, ...) \ - virReportErrorHelper(VIR_FROM_SECRET, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) #define virLibStreamError(code, ...) \ virReportErrorHelper(VIR_FROM_STREAMS, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) @@ -14938,11 +14935,8 @@ virSecretGetConnect(virSecretPtr secret) virResetLastError(); - if (!VIR_IS_CONNECTED_SECRET(secret)) { - virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckSecretReturn(secret, NULL); + return secret->conn; } @@ -15261,11 +15255,7 @@ virSecretGetUUID(virSecretPtr secret, unsigned char *uuid) virResetLastError(); - if (!VIR_IS_CONNECTED_SECRET(secret)) { - virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckSecretReturn(secret, -1); virCheckNonNullArgGoto(uuid, error); memcpy(uuid, &secret->uuid[0], VIR_UUID_BUFLEN); @@ -15295,11 +15285,7 @@ virSecretGetUUIDString(virSecretPtr secret, char *buf) virResetLastError(); - if (!VIR_IS_SECRET(secret)) { - virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckSecretReturn(secret, -1); virCheckNonNullArgGoto(buf, error); virUUIDFormat(secret->uuid, buf); @@ -15331,11 +15317,8 @@ virSecretGetUsageType(virSecretPtr secret) virResetLastError(); - if (!VIR_IS_SECRET(secret)) { - virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckSecretReturn(secret, -1); + return secret->usageType; } @@ -15363,11 +15346,8 @@ virSecretGetUsageID(virSecretPtr secret) virResetLastError(); - if (!VIR_IS_SECRET(secret)) { - virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckSecretReturn(secret, NULL); + return secret->usageID; } @@ -15391,13 +15371,9 @@ virSecretGetXMLDesc(virSecretPtr secret, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_SECRET(secret)) { - virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckSecretReturn(secret, NULL); conn = secret->conn; + if (conn->secretDriver != NULL && conn->secretDriver->secretGetXMLDesc != NULL) { char *ret; @@ -15437,12 +15413,9 @@ virSecretSetValue(virSecretPtr secret, const unsigned char *value, virResetLastError(); - if (!VIR_IS_CONNECTED_SECRET(secret)) { - virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckSecretReturn(secret, -1); conn = secret->conn; + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(value, error); @@ -15483,12 +15456,9 @@ virSecretGetValue(virSecretPtr secret, size_t *value_size, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_SECRET(secret)) { - virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckSecretReturn(secret, NULL); conn = secret->conn; + virCheckReadOnlyGoto(conn->flags, error); virCheckNonNullArgGoto(value_size, error); @@ -15527,12 +15497,9 @@ virSecretUndefine(virSecretPtr secret) virResetLastError(); - if (!VIR_IS_CONNECTED_SECRET(secret)) { - virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckSecretReturn(secret, -1); conn = secret->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->secretDriver != NULL && conn->secretDriver->secretUndefine != NULL) { @@ -15576,11 +15543,8 @@ virSecretRef(virSecretPtr secret) virResetLastError(); - if (!VIR_IS_CONNECTED_SECRET(secret)) { - virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckSecretReturn(secret, -1); + virObjectRef(secret); return 0; } @@ -15601,11 +15565,8 @@ virSecretFree(virSecretPtr secret) virResetLastError(); - if (!VIR_IS_CONNECTED_SECRET(secret)) { - virLibSecretError(VIR_ERR_INVALID_SECRET, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckSecretReturn(secret, -1); + virObjectUnref(secret); return 0; } -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
While all errors related to invalid secrets appeared to be consistent, we might as well continue the trend of using a common macro. For now, we don't need virCheckSecretGoto().
* src/datatypes.h (virCheckSecretReturn): New macro. (VIR_IS_SECRET, VIR_IS_CONNECTED_SECRET): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibSecretError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 ++++++++++--- src/libvirt.c | 79 +++++++++++++++------------------------------------------ 2 files changed, 33 insertions(+), 63 deletions(-)
Similar to previous the GetUUIDString, GetUsageType, and GetUsageID functions now require a valid connection... although GetUUID checked the connection in the old code. ACK John

On 01/02/2014 05:36 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
While all errors related to invalid secrets appeared to be consistent, we might as well continue the trend of using a common macro. For now, we don't need virCheckSecretGoto().
* src/datatypes.h (virCheckSecretReturn): New macro. (VIR_IS_SECRET, VIR_IS_CONNECTED_SECRET): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibSecretError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 ++++++++++--- src/libvirt.c | 79 +++++++++++++++------------------------------------------ 2 files changed, 33 insertions(+), 63 deletions(-)
Similar to previous the GetUUIDString, GetUsageType, and GetUsageID functions now require a valid connection... although GetUUID checked the connection in the old code.
And as before, an updated commit message mentions it is intentional.
ACK
Pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

For streams validation, we weren't consistent on whether to use VIR_FROM_NONE or VIR_FROM_STREAMS. Furthermore, in many API, we want to ensure that a stream is tied to the same connection as the other object we are operating on; while other API failed to validate the stream at all. Similar to previous patches, use a common macro to make it nicer. * src/datatypes.h (virCheckStreamReturn, virCheckStreamGoto): New macros. (VIR_IS_STREAM, VIR_IS_CONNECTED_STREAM): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibStreamError): Drop unused macro. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 29 +++++++++++-- src/libvirt.c | 128 ++++++++++++++++++++++---------------------------------- 2 files changed, 76 insertions(+), 81 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index 024a2e3..6f092a7 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -192,10 +192,31 @@ extern virClassPtr virStoragePoolClass; } \ } while (0) -# define VIR_IS_STREAM(obj) \ - (virObjectIsClass((obj), virStreamClass)) -# define VIR_IS_CONNECTED_STREAM(obj) \ - (VIR_IS_STREAM(obj) && virObjectIsClass((obj)->conn, virConnectClass)) +# define virCheckStreamReturn(obj, retval) \ + do { \ + virStreamPtr _st = (obj); \ + if (!virObjectIsClass(_st, virStreamClass) || \ + !virObjectIsClass(_st->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_STREAMS, \ + VIR_ERR_INVALID_STREAM, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) +# define virCheckStreamGoto(obj, label) \ + do { \ + virStreamPtr _st = (obj); \ + if (!virObjectIsClass(_st, virStreamClass) || \ + !virObjectIsClass(_st->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_STREAMS, \ + VIR_ERR_INVALID_STREAM, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + goto label; \ + } \ + } while (0) # define VIR_IS_NWFILTER(obj) \ (virObjectIsClass((obj), virNWFilterClass)) diff --git a/src/libvirt.c b/src/libvirt.c index eaa4c89..b460c00 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -518,9 +518,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, #define virLibDomainError(code, ...) \ virReportErrorHelper(VIR_FROM_DOM, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) -#define virLibStreamError(code, ...) \ - virReportErrorHelper(VIR_FROM_STREAMS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) #define virLibNWFilterError(code, ...) \ virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) @@ -3076,14 +3073,18 @@ virDomainScreenshot(virDomainPtr domain, virResetLastError(); virCheckDomainReturn(domain, NULL); - if (!VIR_IS_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); - return NULL; + virCheckStreamGoto(stream, error); + virCheckReadOnlyGoto(domain->conn->flags, error); + + if (domain->conn != stream->conn) { + virReportInvalidArg(stream, + _("stream in %s must match connection of domain '%s'"), + __FUNCTION__, domain->name); + goto error; } - virCheckReadOnlyGoto(domain->conn->flags | stream->conn->flags, error); if (domain->conn->driver->domainScreenshot) { - char * ret; + char *ret; ret = domain->conn->driver->domainScreenshot(domain, stream, screen, flags); @@ -13645,14 +13646,16 @@ virStorageVolDownload(virStorageVolPtr vol, virResetLastError(); virCheckStorageVolReturn(vol, -1); + virCheckStreamGoto(stream, error); + virCheckReadOnlyGoto(vol->conn->flags, error); - if (!VIR_IS_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); - return -1; + if (vol->conn != stream->conn) { + virReportInvalidArg(stream, + _("stream in %s must match connection of volume '%s'"), + __FUNCTION__, vol->name); + goto error; } - virCheckReadOnlyGoto(vol->conn->flags | stream->conn->flags, error); - if (vol->conn->storageDriver && vol->conn->storageDriver->storageVolDownload) { int ret; @@ -13709,14 +13712,16 @@ virStorageVolUpload(virStorageVolPtr vol, virResetLastError(); virCheckStorageVolReturn(vol, -1); + virCheckStreamGoto(stream, error); + virCheckReadOnlyGoto(vol->conn->flags, error); - if (!VIR_IS_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); - return -1; + if (vol->conn != stream->conn) { + virReportInvalidArg(stream, + _("stream in %s must match connection of volume '%s'"), + __FUNCTION__, vol->name); + goto error; } - virCheckReadOnlyGoto(vol->conn->flags | stream->conn->flags, error); - if (vol->conn->storageDriver && vol->conn->storageDriver->storageVolUpload) { int ret; @@ -15632,11 +15637,8 @@ virStreamRef(virStreamPtr stream) virResetLastError(); - if ((!VIR_IS_CONNECTED_STREAM(stream))) { - virLibConnError(VIR_ERR_INVALID_STREAM, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStreamReturn(stream, -1); + virObjectRef(stream); return 0; } @@ -15715,12 +15717,7 @@ virStreamSend(virStreamPtr stream, virResetLastError(); - if (!VIR_IS_CONNECTED_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStreamReturn(stream, -1); virCheckNonNullArgGoto(data, error); if (stream->driver && @@ -15813,12 +15810,7 @@ virStreamRecv(virStreamPtr stream, virResetLastError(); - if (!VIR_IS_CONNECTED_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStreamReturn(stream, -1); virCheckNonNullArgGoto(data, error); if (stream->driver && @@ -15892,12 +15884,7 @@ virStreamSendAll(virStreamPtr stream, virResetLastError(); - if (!VIR_IS_CONNECTED_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStreamReturn(stream, -1); virCheckNonNullArgGoto(handler, cleanup); if (stream->flags & VIR_STREAM_NONBLOCK) { @@ -15990,12 +15977,7 @@ virStreamRecvAll(virStreamPtr stream, virResetLastError(); - if (!VIR_IS_CONNECTED_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckStreamReturn(stream, -1); virCheckNonNullArgGoto(handler, cleanup); if (stream->flags & VIR_STREAM_NONBLOCK) { @@ -16064,11 +16046,7 @@ virStreamEventAddCallback(virStreamPtr stream, virResetLastError(); - if (!VIR_IS_CONNECTED_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStreamReturn(stream, -1); if (stream->driver && stream->driver->streamEventAddCallback) { @@ -16107,11 +16085,7 @@ virStreamEventUpdateCallback(virStreamPtr stream, virResetLastError(); - if (!VIR_IS_CONNECTED_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStreamReturn(stream, -1); if (stream->driver && stream->driver->streamEventUpdateCallback) { @@ -16145,11 +16119,7 @@ virStreamEventRemoveCallback(virStreamPtr stream) virResetLastError(); - if (!VIR_IS_CONNECTED_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStreamReturn(stream, -1); if (stream->driver && stream->driver->streamEventRemoveCallback) { @@ -16190,11 +16160,7 @@ virStreamFinish(virStreamPtr stream) virResetLastError(); - if (!VIR_IS_CONNECTED_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStreamReturn(stream, -1); if (stream->driver && stream->driver->streamFinish) { @@ -16233,11 +16199,7 @@ virStreamAbort(virStreamPtr stream) virResetLastError(); - if (!VIR_IS_CONNECTED_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStreamReturn(stream, -1); if (!stream->driver) { VIR_DEBUG("aborting unused stream"); @@ -16281,11 +16243,7 @@ virStreamFree(virStreamPtr stream) virResetLastError(); - if (!VIR_IS_CONNECTED_STREAM(stream)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckStreamReturn(stream, -1); /* XXX Enforce shutdown before free'ing resources ? */ @@ -19293,8 +19251,16 @@ virDomainOpenConsole(virDomainPtr dom, virCheckDomainReturn(dom, -1); conn = dom->conn; + virCheckStreamGoto(st, error); virCheckReadOnlyGoto(conn->flags, error); + if (conn != st->conn) { + virReportInvalidArg(st, + _("stream in %s must match connection of domain '%s'"), + __FUNCTION__, dom->name); + goto error; + } + if (conn->driver->domainOpenConsole) { int ret; ret = conn->driver->domainOpenConsole(dom, dev_name, st, flags); @@ -19349,8 +19315,16 @@ virDomainOpenChannel(virDomainPtr dom, virCheckDomainReturn(dom, -1); conn = dom->conn; + virCheckStreamGoto(st, error); virCheckReadOnlyGoto(conn->flags, error); + if (conn != st->conn) { + virReportInvalidArg(st, + _("stream in %s must match connection of domain '%s'"), + __FUNCTION__, dom->name); + goto error; + } + if (conn->driver->domainOpenChannel) { int ret; ret = conn->driver->domainOpenChannel(dom, name, st, flags); -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
For streams validation, we weren't consistent on whether to use VIR_FROM_NONE or VIR_FROM_STREAMS. Furthermore, in many API, we want to ensure that a stream is tied to the same connection as the other object we are operating on; while other API failed to validate the stream at all. Similar to previous patches, use a common macro to make it nicer.
* src/datatypes.h (virCheckStreamReturn, virCheckStreamGoto): New macros. (VIR_IS_STREAM, VIR_IS_CONNECTED_STREAM): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibStreamError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 29 +++++++++++-- src/libvirt.c | 128 ++++++++++++++++++++++---------------------------------- 2 files changed, 76 insertions(+), 81 deletions(-)
ACK virDomainOpenConsole certainly assumed things previously! John

On 01/02/2014 05:51 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
For streams validation, we weren't consistent on whether to use VIR_FROM_NONE or VIR_FROM_STREAMS. Furthermore, in many API, we want to ensure that a stream is tied to the same connection as the other object we are operating on; while other API failed to validate the stream at all. Similar to previous patches, use a common macro to make it nicer.
* src/datatypes.h (virCheckStreamReturn, virCheckStreamGoto): New macros. (VIR_IS_STREAM, VIR_IS_CONNECTED_STREAM): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibStreamError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 29 +++++++++++-- src/libvirt.c | 128 ++++++++++++++++++++++---------------------------------- 2 files changed, 76 insertions(+), 81 deletions(-)
ACK
virDomainOpenConsole certainly assumed things previously!
Which means this is a bug fix, so I'm justified for pushing it after the freeze :) When I first discovered it, I tried hard to think of any scenarios where it might be abused; I couldn't come up with any, which is why I made the patch public, but I hope I didn't overlook any case for abuse. Now pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

While all errors related to invalid nwfilters appeared to be consistent, we might as well continue the trend of using a common macro. For now, we don't need virCheckNWFilterGoto(). * src/datatypes.h (virCheckNWFilterReturn): New macro. (VIR_IS_NWFILTER, VIR_IS_CONNECTED_NWFILTER): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibNWFilterError): Drop unused macro. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 17 +++++++++++++---- src/libvirt.c | 50 ++++++++++---------------------------------------- 2 files changed, 23 insertions(+), 44 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index 6f092a7..7932a6c 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -218,10 +218,19 @@ extern virClassPtr virStoragePoolClass; } \ } while (0) -# define VIR_IS_NWFILTER(obj) \ - (virObjectIsClass((obj), virNWFilterClass)) -# define VIR_IS_CONNECTED_NWFILTER(obj) \ - (VIR_IS_NWFILTER(obj) && virObjectIsClass((obj)->conn, virConnectClass)) +# define virCheckNWFilterReturn(obj, retval) \ + do { \ + virNWFilterPtr _nw = (obj); \ + if (!virObjectIsClass(_nw, virNWFilterClass) || \ + !virObjectIsClass(_nw->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_NWFILTER, \ + VIR_ERR_INVALID_NWFILTER, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) # define VIR_IS_SNAPSHOT(obj) \ (virObjectIsClass((obj), virDomainSnapshotClass)) diff --git a/src/libvirt.c b/src/libvirt.c index b460c00..9fb69ed 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -518,9 +518,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, #define virLibDomainError(code, ...) \ virReportErrorHelper(VIR_FROM_DOM, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) -#define virLibNWFilterError(code, ...) \ - virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) #define virLibDomainSnapshotError(code, ...) \ virReportErrorHelper(VIR_FROM_DOMAIN_SNAPSHOT, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) @@ -16721,11 +16718,7 @@ virNWFilterFree(virNWFilterPtr nwfilter) virResetLastError(); - if (!VIR_IS_CONNECTED_NWFILTER(nwfilter)) { - virLibNWFilterError(VIR_ERR_INVALID_NWFILTER, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNWFilterReturn(nwfilter, -1); virObjectUnref(nwfilter); return 0; @@ -16748,11 +16741,8 @@ virNWFilterGetName(virNWFilterPtr nwfilter) virResetLastError(); - if (!VIR_IS_NWFILTER(nwfilter)) { - virLibNWFilterError(VIR_ERR_INVALID_NWFILTER, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckNWFilterReturn(nwfilter, NULL); + return nwfilter->name; } @@ -16773,11 +16763,7 @@ virNWFilterGetUUID(virNWFilterPtr nwfilter, unsigned char *uuid) virResetLastError(); - if (!VIR_IS_NWFILTER(nwfilter)) { - virLibNWFilterError(VIR_ERR_INVALID_NWFILTER, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNWFilterReturn(nwfilter, -1); virCheckNonNullArgGoto(uuid, error); memcpy(uuid, &nwfilter->uuid[0], VIR_UUID_BUFLEN); @@ -16807,11 +16793,7 @@ virNWFilterGetUUIDString(virNWFilterPtr nwfilter, char *buf) virResetLastError(); - if (!VIR_IS_NWFILTER(nwfilter)) { - virLibNWFilterError(VIR_ERR_INVALID_NWFILTER, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNWFilterReturn(nwfilter, -1); virCheckNonNullArgGoto(buf, error); virUUIDFormat(nwfilter->uuid, buf); @@ -16878,13 +16860,9 @@ virNWFilterUndefine(virNWFilterPtr nwfilter) virResetLastError(); - if (!VIR_IS_CONNECTED_NWFILTER(nwfilter)) { - virLibNWFilterError(VIR_ERR_INVALID_NWFILTER, __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckNWFilterReturn(nwfilter, -1); conn = nwfilter->conn; + virCheckReadOnlyGoto(conn->flags, error); if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterUndefine) { @@ -16922,12 +16900,7 @@ virNWFilterGetXMLDesc(virNWFilterPtr nwfilter, unsigned int flags) virResetLastError(); - if (!VIR_IS_CONNECTED_NWFILTER(nwfilter)) { - virLibNWFilterError(VIR_ERR_INVALID_NWFILTER, __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckNWFilterReturn(nwfilter, NULL); conn = nwfilter->conn; if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterGetXMLDesc) { @@ -16971,11 +16944,8 @@ virNWFilterRef(virNWFilterPtr nwfilter) virResetLastError(); - if ((!VIR_IS_CONNECTED_NWFILTER(nwfilter))) { - virLibConnError(VIR_ERR_INVALID_NWFILTER, __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckNWFilterReturn(nwfilter, -1); + virObjectRef(nwfilter); return 0; } -- 1.8.4.2

The existing check of domain snapshots validated that they point to a domain, but did not validate that the domain points to a connection, even though any errors blindly assume the connection is valid. For consistency with previous patches, continue the trend of using a common macro. For now, we don't need virCheckDomainSnapshotGoto(). * src/datatypes.h (virCheckDomainSnapshotReturn): New macro. (VIR_IS_SNAPSHOT, VIR_IS_DOMAIN_SNAPSHOT): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibDomainSnapshotError): Drop unused macro. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 18 +++++++-- src/libvirt.c | 118 +++++++++++--------------------------------------------- 2 files changed, 36 insertions(+), 100 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index 7932a6c..10eeebb 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -232,10 +232,20 @@ extern virClassPtr virStoragePoolClass; } \ } while (0) -# define VIR_IS_SNAPSHOT(obj) \ - (virObjectIsClass((obj), virDomainSnapshotClass)) -# define VIR_IS_DOMAIN_SNAPSHOT(obj) \ - (VIR_IS_SNAPSHOT(obj) && virObjectIsClass((obj)->domain, virDomainClass)) +# define virCheckDomainSnapshotReturn(obj, retval) \ + do { \ + virDomainSnapshotPtr _snap = (obj); \ + if (!virObjectIsClass(_snap, virNWFilterClass) || \ + !virObjectIsClass(_snap->domain, virDomainClass) || \ + !virObjectIsClass(_snap->domain->conn, virConnectClass)) { \ + virReportErrorHelper(VIR_FROM_DOMAIN_SNAPSHOT, \ + VIR_ERR_INVALID_DOMAIN_SNAPSHOT, \ + __FILE__, __FUNCTION__, __LINE__, \ + __FUNCTION__); \ + virDispatchError(NULL); \ + return retval; \ + } \ + } while (0) /* Helper macros to implement VIR_DOMAIN_DEBUG using just C99. This diff --git a/src/libvirt.c b/src/libvirt.c index 9fb69ed..a74bfc7 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -518,9 +518,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, #define virLibDomainError(code, ...) \ virReportErrorHelper(VIR_FROM_DOM, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) -#define virLibDomainSnapshotError(code, ...) \ - virReportErrorHelper(VIR_FROM_DOMAIN_SNAPSHOT, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) /** @@ -17940,12 +17937,8 @@ virDomainSnapshotGetName(virDomainSnapshotPtr snapshot) virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainSnapshotReturn(snapshot, NULL); + return snapshot->name; } @@ -17970,12 +17963,8 @@ virDomainSnapshotGetDomain(virDomainSnapshotPtr snapshot) virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainSnapshotReturn(snapshot, NULL); + return snapshot->domain; } @@ -18000,12 +17989,8 @@ virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot) virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return NULL; - } + virCheckDomainSnapshotReturn(snapshot, NULL); + return snapshot->domain->conn; } @@ -18185,13 +18170,7 @@ virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckDomainSnapshotReturn(snapshot, NULL); conn = snapshot->domain->conn; if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) { @@ -18500,14 +18479,9 @@ virDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, unsigned int flags) virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainSnapshotReturn(snapshot, -1); conn = snapshot->domain->conn; + if (conn->driver->domainSnapshotNumChildren) { int ret = conn->driver->domainSnapshotNumChildren(snapshot, flags); if (ret < 0) @@ -18591,13 +18565,7 @@ virDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot, virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainSnapshotReturn(snapshot, -1); conn = snapshot->domain->conn; virCheckNonNullArgGoto(names, error); @@ -18685,13 +18653,7 @@ virDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot, if (snaps) *snaps = NULL; - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainSnapshotReturn(snapshot, -1); conn = snapshot->domain->conn; if (conn->driver->domainSnapshotListAllChildren) { @@ -18847,13 +18809,7 @@ virDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return NULL; - } - + virCheckDomainSnapshotReturn(snapshot, NULL); conn = snapshot->domain->conn; if (conn->driver->domainSnapshotGetParent) { @@ -18891,13 +18847,7 @@ virDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainSnapshotReturn(snapshot, -1); conn = snapshot->domain->conn; if (conn->driver->domainSnapshotIsCurrent) { @@ -18936,13 +18886,7 @@ virDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainSnapshotReturn(snapshot, -1); conn = snapshot->domain->conn; if (conn->driver->domainSnapshotHasMetadata) { @@ -19013,14 +18957,9 @@ virDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainSnapshotReturn(snapshot, -1); conn = snapshot->domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if ((flags & VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING) && @@ -19079,14 +19018,9 @@ virDomainSnapshotDelete(virDomainSnapshotPtr snapshot, virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return -1; - } - + virCheckDomainSnapshotReturn(snapshot, -1); conn = snapshot->domain->conn; + virCheckReadOnlyGoto(conn->flags, error); if ((flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) && @@ -19137,12 +19071,8 @@ virDomainSnapshotRef(virDomainSnapshotPtr snapshot) virResetLastError(); - if ((!VIR_IS_DOMAIN_SNAPSHOT(snapshot))) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainSnapshotReturn(snapshot, -1); + virObjectRef(snapshot); return 0; } @@ -19164,12 +19094,8 @@ virDomainSnapshotFree(virDomainSnapshotPtr snapshot) virResetLastError(); - if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) { - virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, - __FUNCTION__); - virDispatchError(NULL); - return -1; - } + virCheckDomainSnapshotReturn(snapshot, -1); + virObjectUnref(snapshot); return 0; } -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
The existing check of domain snapshots validated that they point to a domain, but did not validate that the domain points to a connection, even though any errors blindly assume the connection is valid. For consistency with previous patches, continue the trend of using a common macro. For now, we don't need virCheckDomainSnapshotGoto().
* src/datatypes.h (virCheckDomainSnapshotReturn): New macro. (VIR_IS_SNAPSHOT, VIR_IS_DOMAIN_SNAPSHOT): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibDomainSnapshotError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 18 +++++++-- src/libvirt.c | 118 +++++++++++--------------------------------------------- 2 files changed, 36 insertions(+), 100 deletions(-)
Still paying attention (barely)... GetName, GetUUID, and GetUUIDString will all now require the connection ACK John

On 01/02/2014 07:53 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
The existing check of domain snapshots validated that they point to a domain, but did not validate that the domain points to a connection, even though any errors blindly assume the connection is valid. For consistency with previous patches, continue the trend of using a common macro. For now, we don't need virCheckDomainSnapshotGoto().
* src/datatypes.h (virCheckDomainSnapshotReturn): New macro. (VIR_IS_SNAPSHOT, VIR_IS_DOMAIN_SNAPSHOT): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibDomainSnapshotError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 18 +++++++-- src/libvirt.c | 118 +++++++++++--------------------------------------------- 2 files changed, 36 insertions(+), 100 deletions(-)
Still paying attention (barely)... GetName, GetUUID, and GetUUIDString will all now require the connection
Guess I wasn't paying that close attention as this was meant for 21/24 :-) John
ACK
John
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 01/02/2014 06:38 PM, John Ferlan wrote:
On 01/02/2014 07:53 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
The existing check of domain snapshots validated that they point to a domain, but did not validate that the domain points to a connection, even though any errors blindly assume the connection is valid. For consistency with previous patches, continue the trend of using a common macro. For now, we don't need virCheckDomainSnapshotGoto().
Still paying attention (barely)... GetName, GetUUID, and GetUUIDString will all now require the connection
Again intentional, so updated the commit message to mention it.
Guess I wasn't paying that close attention as this was meant for 21/24 :-)
John
ACK
21 is now pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 12/28/2013 11:11 AM, Eric Blake wrote:
The existing check of domain snapshots validated that they point to a domain, but did not validate that the domain points to a connection, even though any errors blindly assume the connection is valid. For consistency with previous patches, continue the trend of using a common macro. For now, we don't need virCheckDomainSnapshotGoto().
* src/datatypes.h (virCheckDomainSnapshotReturn): New macro. (VIR_IS_SNAPSHOT, VIR_IS_DOMAIN_SNAPSHOT): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibDomainSnapshotError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 18 +++++++-- src/libvirt.c | 118 +++++++++++--------------------------------------------- 2 files changed, 36 insertions(+), 100 deletions(-)
ACK John

On 01/02/2014 05:55 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
The existing check of domain snapshots validated that they point to a domain, but did not validate that the domain points to a connection, even though any errors blindly assume the connection is valid. For consistency with previous patches, continue the trend of using a common macro. For now, we don't need virCheckDomainSnapshotGoto().
* src/datatypes.h (virCheckDomainSnapshotReturn): New macro. (VIR_IS_SNAPSHOT, VIR_IS_DOMAIN_SNAPSHOT): Drop unused macros. * src/libvirt.c: Use macro throughout. (virLibDomainSnapshotError): Drop unused macro.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/datatypes.h | 18 +++++++-- src/libvirt.c | 118 +++++++++++--------------------------------------------- 2 files changed, 36 insertions(+), 100 deletions(-)
ACK
22 is pushed, after squashing in this obvious fix which would have broken all snapshot APIs (bummer that 'make check' didn't catch it, seems like something where snapshot probing of test:/// should have caught this...; a trivial 'virsh -c test:///default snapshot-create test' was enough to expose it) diff --git i/src/datatypes.h w/src/datatypes.h index 999065f..9621c55 100644 --- i/src/datatypes.h +++ w/src/datatypes.h @@ -235,7 +235,7 @@ extern virClassPtr virStoragePoolClass; # define virCheckDomainSnapshotReturn(obj, retval) \ do { \ virDomainSnapshotPtr _snap = (obj); \ - if (!virObjectIsClass(_snap, virNWFilterClass) || \ + if (!virObjectIsClass(_snap, virDomainSnapshotClass) || \ !virObjectIsClass(_snap->domain, virDomainClass) || \ !virObjectIsClass(_snap->domain->conn, virConnectClass)) { \ virReportErrorHelper(VIR_FROM_DOMAIN_SNAPSHOT, \ [Do you ever wonder if I sneak in blatant bugs in large series, just to see if anyone is paying attention?] -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

While auditing the error reporting, I noticed that migration had some issues. Some of the static helper functions tried to call virDispatchError(), even though their caller will also report the error. Also, if a migration is cancelled early because a uri was not set, we did not guarantee that the finish stage would not overwrite the first error message. * src/qemu/qemu_migration.c (doPeer2PeerMigrate2) (doPeer2PeerMigrate3): Preserve first error when cancelling. * src/libvirt.c (virDomainMigrateVersion3Full): Likewise. (virDomainMigrateVersion1, virDomainMigrateVersion2) (virDomainMigrateDirect): Avoid redundant error dispatch. (virDomainMigrateFinish2, virDomainMigrateFinish3) (virDomainMigrateFinish3Params): Don't report error on cleanup path. (virDomainMigratePeer2PeerFull, virDomainMigrateDirect) (virDomainMigrate2): Use correct errors. (virDomainMigrate*): Prefer virReportError over virLibConnError. Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 181 ++++++++++++++++++++++++---------------------- src/qemu/qemu_migration.c | 10 ++- 2 files changed, 104 insertions(+), 87 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index a74bfc7..637bfc1 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -4452,8 +4452,8 @@ virDomainMigrateVersion1(virDomainPtr domain, goto done; if (uri == NULL && uri_out == NULL) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("domainMigratePrepare did not set uri")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("domainMigratePrepare did not set uri")); goto done; } if (uri_out) @@ -4544,8 +4544,7 @@ virDomainMigrateVersion2(virDomainPtr domain, * and pass it to Prepare2. */ if (!domain->conn->driver->domainGetXMLDesc) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__); - virDispatchError(domain->conn); + virReportUnsupportedError(); return NULL; } @@ -4575,10 +4574,11 @@ virDomainMigrateVersion2(virDomainPtr domain, goto done; if (uri == NULL && uri_out == NULL) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("domainMigratePrepare2 did not set uri")); - virDispatchError(domain->conn); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("domainMigratePrepare2 did not set uri")); cancelled = 1; + /* Make sure Finish doesn't overwrite the error */ + orig_err = virSaveLastError(); goto finish; } if (uri_out) @@ -4609,6 +4609,8 @@ finish: VIR_DEBUG("Finish2 %p ret=%d", dconn, ret); ddomain = dconn->driver->domainMigrateFinish2 (dconn, dname, cookie, cookielen, uri, destflags, cancelled); + if (cancelled && ddomain) + VIR_ERROR(_("finish step ignored that migration was cancelled")); done: if (orig_err) { @@ -4697,7 +4699,7 @@ virDomainMigrateVersion3Full(virDomainPtr domain, !domain->conn->driver->domainMigrateConfirm3Params || !dconn->driver->domainMigratePrepare3Params || !dconn->driver->domainMigrateFinish3Params))) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__); + virReportUnsupportedError(); return NULL; } @@ -4771,13 +4773,19 @@ virDomainMigrateVersion3Full(virDomainPtr domain, if (useParams && virTypedParamsReplaceString(¶ms, &nparams, VIR_MIGRATE_PARAM_URI, - uri_out) < 0) + uri_out) < 0) { + cancelled = 1; + orig_err = virSaveLastError(); goto finish; + } } else if (!uri && virTypedParamsGetString(params, nparams, VIR_MIGRATE_PARAM_URI, &uri) <= 0) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("domainMigratePrepare3 did not set uri")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("domainMigratePrepare3 did not set uri")); + cancelled = 1; + orig_err = virSaveLastError(); + goto finish; } if (flags & VIR_MIGRATE_OFFLINE) { @@ -4856,6 +4864,8 @@ finish: (dconn, dname, cookiein, cookieinlen, &cookieout, &cookieoutlen, NULL, uri, destflags, cancelled); } + if (cancelled && ddomain) + VIR_ERROR(_("finish step ignored that migration was cancelled")); /* If ddomain is NULL, then we were unable to start * the guest on the target, and must restart on the @@ -4984,7 +4994,7 @@ virDomainMigratePeer2PeerFull(virDomainPtr domain, (!useParams && !domain->conn->driver->domainMigratePerform && !domain->conn->driver->domainMigratePerform3)) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__); + virReportUnsupportedError(); return -1; } @@ -5013,14 +5023,14 @@ virDomainMigratePeer2PeerFull(virDomainPtr domain, } else { VIR_DEBUG("Using migration protocol 2"); if (xmlin) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("Unable to change target guest XML " - "during migration")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Unable to change target guest XML during " + "migration")); return -1; } if (uri) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to override peer2peer migration URI")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to override peer2peer migration URI")); return -1; } return domain->conn->driver->domainMigratePerform @@ -5081,7 +5091,6 @@ virDomainMigrateDirect(virDomainPtr domain, if (!domain->conn->driver->domainMigratePerform) { virReportUnsupportedError(); - virDispatchError(domain->conn); return -1; } @@ -5107,8 +5116,8 @@ virDomainMigrateDirect(virDomainPtr domain, } else { VIR_DEBUG("Using migration protocol 2"); if (xmlin) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to change target guest XML during migration")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Unable to change target guest XML during migration")); return -1; } return domain->conn->driver->domainMigratePerform(domain, @@ -5236,16 +5245,16 @@ virDomainMigrate(virDomainPtr domain, if (flags & VIR_MIGRATE_OFFLINE) { if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the source host")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the source host")); goto error; } if (!VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the destination host")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the destination host")); goto error; } } @@ -5283,14 +5292,14 @@ virDomainMigrate(virDomainPtr domain, if (flags & VIR_MIGRATE_CHANGE_PROTECTION && !VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION)) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("cannot enforce change protection")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("cannot enforce change protection")); goto error; } flags &= ~VIR_MIGRATE_CHANGE_PROTECTION; if (flags & VIR_MIGRATE_TUNNELLED) { - virLibConnError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot perform tunnelled migration without using peer2peer flag")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot perform tunnelled migration without using peer2peer flag")); goto error; } @@ -5462,16 +5471,16 @@ virDomainMigrate2(virDomainPtr domain, if (flags & VIR_MIGRATE_OFFLINE) { if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the source host")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the source host")); goto error; } if (!VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the destination host")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the destination host")); goto error; } } @@ -5506,14 +5515,14 @@ virDomainMigrate2(virDomainPtr domain, if (flags & VIR_MIGRATE_CHANGE_PROTECTION && !VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION)) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("cannot enforce change protection")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("cannot enforce change protection")); goto error; } flags &= ~VIR_MIGRATE_CHANGE_PROTECTION; if (flags & VIR_MIGRATE_TUNNELLED) { - virLibConnError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot perform tunnelled migration without using peer2peer flag")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot perform tunnelled migration without using peer2peer flag")); goto error; } @@ -5531,8 +5540,8 @@ virDomainMigrate2(virDomainPtr domain, VIR_DRV_FEATURE_MIGRATION_V2)) { VIR_DEBUG("Using migration protocol 2"); if (dxml) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to change target guest XML during migration")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Unable to change target guest XML during migration")); goto error; } ddomain = virDomainMigrateVersion2(domain, dconn, flags, @@ -5543,8 +5552,8 @@ virDomainMigrate2(virDomainPtr domain, VIR_DRV_FEATURE_MIGRATION_V1)) { VIR_DEBUG("Using migration protocol 1"); if (dxml) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to change target guest XML during migration")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Unable to change target guest XML during migration")); goto error; } ddomain = virDomainMigrateVersion1(domain, dconn, flags, @@ -5645,16 +5654,16 @@ virDomainMigrate3(virDomainPtr domain, if (flags & VIR_MIGRATE_OFFLINE) { if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the source host")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the source host")); goto error; } if (!VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn, VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the destination host")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the destination host")); goto error; } } @@ -5667,8 +5676,8 @@ virDomainMigrate3(virDomainPtr domain, if (flags & VIR_MIGRATE_CHANGE_PROTECTION && !VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION)) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("cannot enforce change protection")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("cannot enforce change protection")); goto error; } flags &= ~VIR_MIGRATE_CHANGE_PROTECTION; @@ -5687,9 +5696,9 @@ virDomainMigrate3(virDomainPtr domain, if (!virTypedParamsCheck(params, nparams, compatParams, ARRAY_CARDINALITY(compatParams))) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("Migration APIs with extensible parameters are not " - "supported but extended parameters were passed")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Migration APIs with extensible parameters are not " + "supported but extended parameters were passed")); goto error; } @@ -5717,9 +5726,9 @@ virDomainMigrate3(virDomainPtr domain, VIR_DRV_FEATURE_MIGRATION_V2)) { VIR_DEBUG("Using migration protocol 2"); if (dxml) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("Unable to change target guest XML during " - "migration")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Unable to change target guest XML during " + "migration")); goto error; } ddomain = virDomainMigrateVersion2(domain, dconn, flags, @@ -5730,9 +5739,9 @@ virDomainMigrate3(virDomainPtr domain, VIR_DRV_FEATURE_MIGRATION_V1)) { VIR_DEBUG("Using migration protocol 1"); if (dxml) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("Unable to change target guest XML during " - "migration")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Unable to change target guest XML during " + "migration")); goto error; } ddomain = virDomainMigrateVersion1(domain, dconn, flags, @@ -5856,9 +5865,9 @@ virDomainMigrateToURI(virDomainPtr domain, if (flags & VIR_MIGRATE_OFFLINE && !VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("offline migration is not supported by " - "the source host")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("offline migration is not supported by " + "the source host")); goto error; } @@ -5883,9 +5892,9 @@ virDomainMigrateToURI(virDomainPtr domain, goto error; } else { /* Cannot do a migration with only the perform step */ - virLibConnError(VIR_ERR_OPERATION_INVALID, "%s", - _("direct migration is not supported by the" - " connection driver")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("direct migration is not supported by the" + " connection driver")); goto error; } } @@ -6031,9 +6040,9 @@ virDomainMigrateToURI2(virDomainPtr domain, goto error; } else { /* Cannot do a migration with only the perform step */ - virLibConnError(VIR_ERR_OPERATION_INVALID, "%s", - _("direct migration is not supported by the" - " connection driver")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("direct migration is not supported by the" + " connection driver")); goto error; } } @@ -6136,9 +6145,9 @@ virDomainMigrateToURI3(virDomainPtr domain, if (flags & VIR_MIGRATE_PEER2PEER) { if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_P2P)) { - virLibConnError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("Peer-to-peer migration is not supported by " - "the connection driver")); + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Peer-to-peer migration is not supported by " + "the connection driver")); goto error; } @@ -6154,26 +6163,26 @@ virDomainMigrateToURI3(virDomainPtr domain, dconnuri, uri, bandwidth) < 0) goto error; } else { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("Peer-to-peer migration with extensible " - "parameters is not supported but extended " - "parameters were passed")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Peer-to-peer migration with extensible " + "parameters is not supported but extended " + "parameters were passed")); goto error; } } else { if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_DIRECT)) { /* Cannot do a migration with only the perform step */ - virLibConnError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("Direct migration is not supported by the" - " connection driver")); + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Direct migration is not supported by the" + " connection driver")); goto error; } if (!compat) { - virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("Direct migration does not support extensible " - "parameters")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Direct migration does not support extensible " + "parameters")); goto error; } @@ -6387,7 +6396,7 @@ virDomainMigrateFinish2(virConnectPtr dconn, cookie, cookielen, uri, flags, retcode); - if (!ret) + if (!ret && !retcode) goto error; return ret; } @@ -6679,7 +6688,7 @@ virDomainMigrateFinish3(virConnectPtr dconn, cookieout, cookieoutlen, dconnuri, uri, flags, cancelled); - if (!ret) + if (!ret && !cancelled) goto error; return ret; } @@ -6954,7 +6963,7 @@ virDomainMigrateFinish3Params(virConnectPtr dconn, ret = dconn->driver->domainMigrateFinish3Params( dconn, params, nparams, cookiein, cookieinlen, cookieout, cookieoutlen, flags, cancelled); - if (!ret) + if (!ret && !cancelled) goto error; return ret; } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 9342062..8344a45 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3569,6 +3569,7 @@ static int doPeer2PeerMigrate2(virQEMUDriverPtr driver, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("domainMigratePrepare2 did not set uri")); cancelled = true; + orig_err = virSaveLastError(); goto finish; } @@ -3608,6 +3609,8 @@ finish: (dconn, dname, cookie, cookielen, uri_out ? uri_out : dconnuri, destflags, cancelled); qemuDomainObjExitRemote(vm); + if (cancelled && ddomain) + VIR_ERROR(_("finish step ignored that migration was cancelled")); cleanup: if (ddomain) { @@ -3769,11 +3772,14 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver, uri = uri_out; if (useParams && virTypedParamsReplaceString(¶ms, &nparams, - VIR_MIGRATE_PARAM_URI, uri_out) < 0) + VIR_MIGRATE_PARAM_URI, uri_out) < 0) { + orig_err = virSaveLastError(); goto finish; + } } else if (!uri && !(flags & VIR_MIGRATE_TUNNELLED)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("domainMigratePrepare3 did not set uri")); + orig_err = virSaveLastError(); goto finish; } @@ -3850,6 +3856,8 @@ finish: dconnuri, uri, destflags, cancelled); qemuDomainObjExitRemote(vm); } + if (cancelled && ddomain) + VIR_ERROR(_("finish step ignored that migration was cancelled")); /* If ddomain is NULL, then we were unable to start * the guest on the target, and must restart on the -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
While auditing the error reporting, I noticed that migration had some issues. Some of the static helper functions tried to call virDispatchError(), even though their caller will also report the error. Also, if a migration is cancelled early because a uri was not set, we did not guarantee that the finish stage would not overwrite the first error message.
* src/qemu/qemu_migration.c (doPeer2PeerMigrate2) (doPeer2PeerMigrate3): Preserve first error when cancelling. * src/libvirt.c (virDomainMigrateVersion3Full): Likewise. (virDomainMigrateVersion1, virDomainMigrateVersion2) (virDomainMigrateDirect): Avoid redundant error dispatch. (virDomainMigrateFinish2, virDomainMigrateFinish3) (virDomainMigrateFinish3Params): Don't report error on cleanup path. (virDomainMigratePeer2PeerFull, virDomainMigrateDirect) (virDomainMigrate2): Use correct errors. (virDomainMigrate*): Prefer virReportError over virLibConnError.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 181 ++++++++++++++++++++++++---------------------- src/qemu/qemu_migration.c | 10 ++- 2 files changed, 104 insertions(+), 87 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index a74bfc7..637bfc1 100644 --- a/src/libvirt.c +++ b/src/libvirt.c
<...snip...>
@@ -6387,7 +6396,7 @@ virDomainMigrateFinish2(virConnectPtr dconn, cookie, cookielen, uri, flags, retcode); - if (!ret) + if (!ret && !retcode)
This one (and the two below) feel like a bug fix unrelated to error reporting/processing...
goto error; return ret; } @@ -6679,7 +6688,7 @@ virDomainMigrateFinish3(virConnectPtr dconn, cookieout, cookieoutlen, dconnuri, uri, flags, cancelled); - if (!ret) + if (!ret && !cancelled)
here..
goto error; return ret; } @@ -6954,7 +6963,7 @@ virDomainMigrateFinish3Params(virConnectPtr dconn, ret = dconn->driver->domainMigrateFinish3Params( dconn, params, nparams, cookiein, cookieinlen, cookieout, cookieoutlen, flags, cancelled); - if (!ret) + if (!ret && !cancelled)
here...
goto error; return ret; }
ACK in general - your call on whether to split out the extra checks pointed out above or leave things as they are. If in fact those are "bugs" that "should" go into a RHEL release, then perhaps they need to be separated... John

On 01/02/2014 06:57 PM, John Ferlan wrote:
On 12/28/2013 11:11 AM, Eric Blake wrote:
While auditing the error reporting, I noticed that migration had some issues. Some of the static helper functions tried to call virDispatchError(), even though their caller will also report the error. Also, if a migration is cancelled early because a uri was not set, we did not guarantee that the finish stage would not overwrite the first error message.
* src/qemu/qemu_migration.c (doPeer2PeerMigrate2) (doPeer2PeerMigrate3): Preserve first error when cancelling. * src/libvirt.c (virDomainMigrateVersion3Full): Likewise. (virDomainMigrateVersion1, virDomainMigrateVersion2) (virDomainMigrateDirect): Avoid redundant error dispatch. (virDomainMigrateFinish2, virDomainMigrateFinish3) (virDomainMigrateFinish3Params): Don't report error on cleanup path. (virDomainMigratePeer2PeerFull, virDomainMigrateDirect) (virDomainMigrate2): Use correct errors. (virDomainMigrate*): Prefer virReportError over virLibConnError.
Signed-off-by: Eric Blake <eblake@redhat.com> --- src/libvirt.c | 181 ++++++++++++++++++++++++---------------------- src/qemu/qemu_migration.c | 10 ++- 2 files changed, 104 insertions(+), 87 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index a74bfc7..637bfc1 100644 --- a/src/libvirt.c +++ b/src/libvirt.c
<...snip...>
@@ -6387,7 +6396,7 @@ virDomainMigrateFinish2(virConnectPtr dconn, cookie, cookielen, uri, flags, retcode); - if (!ret) + if (!ret && !retcode)
This one (and the two below) feel like a bug fix unrelated to error reporting/processing...
Indeed; I'll split this into smaller chunks in my series v2 post, and see if we can git Jirka to look at it as well (since he's familiar with migration error scenarios).
ACK in general - your call on whether to split out the extra checks pointed out above or leave things as they are. If in fact those are "bugs" that "should" go into a RHEL release, then perhaps they need to be separated...
Worth a v2. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Finish the cleanup; all uses of virLib*Error have now been converted to more canonical conventions. * src/libvirt.c: Use virReportError in remaining errors. (virLibConnError, virLibDomainError): Delete unused macros. * cfg.mk (msg_gen_function): Drop unused names. Signed-off-by: Eric Blake <eblake@redhat.com> --- cfg.mk | 10 ---- src/libvirt.c | 158 +++++++++++++++++++++++++++------------------------------- 2 files changed, 74 insertions(+), 94 deletions(-) diff --git a/cfg.mk b/cfg.mk index 5591065..e7515ea 100644 --- a/cfg.mk +++ b/cfg.mk @@ -585,16 +585,6 @@ msg_gen_function += regerror msg_gen_function += vah_error msg_gen_function += vah_warning msg_gen_function += virGenericReportError -msg_gen_function += virLibConnError -msg_gen_function += virLibDomainError -msg_gen_function += virLibDomainSnapshotError -msg_gen_function += virLibInterfaceError -msg_gen_function += virLibNetworkError -msg_gen_function += virLibNodeDeviceError -msg_gen_function += virLibNWFilterError -msg_gen_function += virLibSecretError -msg_gen_function += virLibStoragePoolError -msg_gen_function += virLibStorageVolError msg_gen_function += virRaiseError msg_gen_function += virReportError msg_gen_function += virReportErrorHelper diff --git a/src/libvirt.c b/src/libvirt.c index 637bfc1..42f1139 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -512,14 +512,6 @@ DllMain(HINSTANCE instance ATTRIBUTE_UNUSED, #endif -#define virLibConnError(code, ...) \ - virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) -#define virLibDomainError(code, ...) \ - virReportErrorHelper(VIR_FROM_DOM, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - - /** * virRegisterNetworkDriver: * @driver: pointer to a network driver block @@ -534,9 +526,9 @@ virRegisterNetworkDriver(virNetworkDriverPtr driver) virCheckNonNullArgReturn(driver, -1); if (virNetworkDriverTabCount >= MAX_DRIVERS) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, - _("Too many drivers, cannot register %s"), - driver->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register %s"), + driver->name); return -1; } @@ -562,9 +554,9 @@ virRegisterInterfaceDriver(virInterfaceDriverPtr driver) virCheckNonNullArgReturn(driver, -1); if (virInterfaceDriverTabCount >= MAX_DRIVERS) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, - _("Too many drivers, cannot register %s"), - driver->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register %s"), + driver->name); return -1; } @@ -590,9 +582,9 @@ virRegisterStorageDriver(virStorageDriverPtr driver) virCheckNonNullArgReturn(driver, -1); if (virStorageDriverTabCount >= MAX_DRIVERS) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, - _("Too many drivers, cannot register %s"), - driver->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register %s"), + driver->name); return -1; } @@ -618,9 +610,9 @@ virRegisterNodeDeviceDriver(virNodeDeviceDriverPtr driver) virCheckNonNullArgReturn(driver, -1); if (virNodeDeviceDriverTabCount >= MAX_DRIVERS) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, - _("Too many drivers, cannot register %s"), - driver->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register %s"), + driver->name); return -1; } @@ -646,9 +638,9 @@ virRegisterSecretDriver(virSecretDriverPtr driver) virCheckNonNullArgReturn(driver, -1); if (virSecretDriverTabCount >= MAX_DRIVERS) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, - _("Too many drivers, cannot register %s"), - driver->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register %s"), + driver->name); return -1; } @@ -674,9 +666,9 @@ virRegisterNWFilterDriver(virNWFilterDriverPtr driver) virCheckNonNullArgReturn(driver, -1); if (virNWFilterDriverTabCount >= MAX_DRIVERS) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, - _("Too many drivers, cannot register %s"), - driver->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register %s"), + driver->name); return -1; } @@ -704,9 +696,9 @@ virRegisterDriver(virDriverPtr driver) virCheckNonNullArgReturn(driver, -1); if (virDriverTabCount >= MAX_DRIVERS) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, - _("Too many drivers, cannot register %s"), - driver->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register %s"), + driver->name); return -1; } @@ -733,9 +725,9 @@ virRegisterStateDriver(virStateDriverPtr driver) virCheckNonNullArgReturn(driver, -1); if (virStateDriverTabCount >= MAX_DRIVERS) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, - _("Too many drivers, cannot register %s"), - driver->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register %s"), + driver->name); return -1; } @@ -970,8 +962,8 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, size_t alias_len; if (value->type != VIR_CONF_LIST) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Expected a list for 'uri_aliases' config parameter")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Expected a list for 'uri_aliases' config parameter")); return -1; } @@ -982,22 +974,22 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, size_t safe; if (entry->type != VIR_CONF_STRING) { - virLibConnError(VIR_ERR_CONF_SYNTAX, "%s", - _("Expected a string for 'uri_aliases' config parameter list entry")); + virReportError(VIR_ERR_CONF_SYNTAX, "%s", + _("Expected a string for 'uri_aliases' config parameter list entry")); return -1; } if (!(offset = strchr(entry->str, '='))) { - virLibConnError(VIR_ERR_CONF_SYNTAX, - _("Malformed 'uri_aliases' config entry '%s', expected 'alias=uri://host/path'"), + virReportError(VIR_ERR_CONF_SYNTAX, + _("Malformed 'uri_aliases' config entry '%s', expected 'alias=uri://host/path'"), entry->str); return -1; } safe = strspn(entry->str, URI_ALIAS_CHARS); if (safe < (offset - entry->str)) { - virLibConnError(VIR_ERR_CONF_SYNTAX, - _("Malformed 'uri_aliases' config entry '%s', aliases may only contain 'a-Z, 0-9, _, -'"), + virReportError(VIR_ERR_CONF_SYNTAX, + _("Malformed 'uri_aliases' config entry '%s', aliases may only contain 'a-Z, 0-9, _, -'"), entry->str); return -1; } @@ -1048,8 +1040,8 @@ virConnectGetDefaultURI(virConfPtr conf, *name = defname; } else if ((value = virConfGetValue(conf, "uri_default"))) { if (value->type != VIR_CONF_STRING) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Expected a string for 'uri_default' config parameter")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Expected a string for 'uri_default' config parameter")); goto cleanup; } VIR_DEBUG("Using config file uri '%s'", value->str); @@ -1194,9 +1186,7 @@ do_open(const char *name, if (!ret->driver) { /* If we reach here, then all drivers declined the connection. */ - virLibConnError(VIR_ERR_NO_CONNECT, - "%s", - NULLSTR(name)); + virReportError(VIR_ERR_NO_CONNECT, "%s", NULLSTR(name)); goto failed; } @@ -2568,8 +2558,8 @@ virDomainSave(virDomainPtr domain, const char *to) /* We must absolutize the file path as the save is done out of process */ if (virFileAbsPath(to, &absolute_to) < 0) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not build absolute output file path")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not build absolute output file path")); goto error; } @@ -2658,8 +2648,8 @@ virDomainSaveFlags(virDomainPtr domain, const char *to, /* We must absolutize the file path as the save is done out of process */ if (virFileAbsPath(to, &absolute_to) < 0) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not build absolute output file path")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not build absolute output file path")); goto error; } @@ -2708,8 +2698,8 @@ virDomainRestore(virConnectPtr conn, const char *from) /* We must absolutize the file path as the restore is done out of process */ if (virFileAbsPath(from, &absolute_from) < 0) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not build absolute input file path")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not build absolute input file path")); goto error; } @@ -2784,8 +2774,8 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml, /* We must absolutize the file path as the restore is done out of process */ if (virFileAbsPath(from, &absolute_from) < 0) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not build absolute input file path")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not build absolute input file path")); goto error; } @@ -2838,8 +2828,8 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file, virCheckNonNullArgGoto(file, error); if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) { - virLibConnError(VIR_ERR_OPERATION_DENIED, "%s", - _("virDomainSaveImageGetXMLDesc with secure flag")); + virReportError(VIR_ERR_OPERATION_DENIED, "%s", + _("virDomainSaveImageGetXMLDesc with secure flag")); goto error; } @@ -2849,8 +2839,8 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file, /* We must absolutize the file path as the read is done out of process */ if (virFileAbsPath(file, &absolute_file) < 0) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not build absolute input file path")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not build absolute input file path")); goto error; } @@ -2924,8 +2914,8 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file, /* We must absolutize the file path as the read is done out of process */ if (virFileAbsPath(file, &absolute_file) < 0) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not build absolute input file path")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not build absolute input file path")); goto error; } @@ -3011,8 +3001,8 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int flags) /* We must absolutize the file path as the save is done out of process */ if (virFileAbsPath(to, &absolute_to) < 0) { - virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not build absolute core file path")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not build absolute core file path")); goto error; } @@ -3471,8 +3461,8 @@ virDomainGetMaxMemory(virDomainPtr domain) if (ret == 0) goto error; if ((unsigned long) ret != ret) { - virLibDomainError(VIR_ERR_OVERFLOW, _("result too large: %llu"), - ret); + virReportError(VIR_ERR_OVERFLOW, _("result too large: %llu"), + ret); goto error; } return ret; @@ -4275,8 +4265,8 @@ virDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) conn = domain->conn; if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) { - virLibConnError(VIR_ERR_OPERATION_DENIED, "%s", - _("virDomainGetXMLDesc with secure flag")); + virReportError(VIR_ERR_OPERATION_DENIED, "%s", + _("virDomainGetXMLDesc with secure flag")); goto error; } @@ -9333,7 +9323,7 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, virCheckNonZeroArgGoto(nvcpus, error); if ((unsigned short) nvcpus != nvcpus) { - virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %u"), nvcpus); + virReportError(VIR_ERR_OVERFLOW, _("input too large: %u"), nvcpus); goto error; } conn = domain->conn; @@ -9460,7 +9450,7 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu, virCheckPositiveArgGoto(maplen, error); if ((unsigned short) vcpu != vcpu) { - virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %u"), vcpu); + virReportError(VIR_ERR_OVERFLOW, _("input too large: %u"), vcpu); goto error; } @@ -9532,7 +9522,7 @@ virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu, virCheckPositiveArgGoto(maplen, error); if ((unsigned short) vcpu != vcpu) { - virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %u"), vcpu); + virReportError(VIR_ERR_OVERFLOW, _("input too large: %u"), vcpu); goto error; } @@ -9595,8 +9585,8 @@ virDomainGetVcpuPinInfo(virDomainPtr domain, int ncpumaps, virCheckPositiveArgGoto(maplen, error); if (INT_MULTIPLY_OVERFLOW(ncpumaps, maplen)) { - virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"), - ncpumaps, maplen); + virReportError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"), + ncpumaps, maplen); goto error; } @@ -9805,8 +9795,8 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo, virCheckZeroArgGoto(maplen, error); if (cpumaps && INT_MULTIPLY_OVERFLOW(maxinfo, maplen)) { - virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"), - maxinfo, maplen); + virReportError(VIR_ERR_OVERFLOW, _("input too large: %d * %d"), + maxinfo, maplen); goto error; } @@ -15891,8 +15881,8 @@ virStreamSendAll(virStreamPtr stream, virCheckNonNullArgGoto(handler, cleanup); if (stream->flags & VIR_STREAM_NONBLOCK) { - virLibConnError(VIR_ERR_OPERATION_INVALID, "%s", - _("data sources cannot be used for non-blocking streams")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("data sources cannot be used for non-blocking streams")); goto cleanup; } @@ -15984,8 +15974,8 @@ virStreamRecvAll(virStreamPtr stream, virCheckNonNullArgGoto(handler, cleanup); if (stream->flags & VIR_STREAM_NONBLOCK) { - virLibConnError(VIR_ERR_OPERATION_INVALID, "%s", - _("data sinks cannot be used for non-blocking streams")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("data sinks cannot be used for non-blocking streams")); goto cleanup; } @@ -18183,8 +18173,8 @@ virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, conn = snapshot->domain->conn; if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) { - virLibConnError(VIR_ERR_OPERATION_DENIED, "%s", - _("virDomainSnapshotGetXMLDesc with secure flag")); + virReportError(VIR_ERR_OPERATION_DENIED, "%s", + _("virDomainSnapshotGetXMLDesc with secure flag")); goto error; } @@ -19919,8 +19909,8 @@ virConnectRegisterCloseCallback(virConnectPtr conn, virCheckNonNullArgGoto(cb, error); if (conn->closeCallback->callback) { - virLibConnError(VIR_ERR_OPERATION_INVALID, "%s", - _("A close callback is already registered")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("A close callback is already registered")); goto error; } @@ -19972,8 +19962,8 @@ virConnectUnregisterCloseCallback(virConnectPtr conn, virCheckNonNullArgGoto(cb, error); if (conn->closeCallback->callback != cb) { - virLibConnError(VIR_ERR_OPERATION_INVALID, "%s", - _("A different callback was requested")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("A different callback was requested")); goto error; } @@ -20261,8 +20251,8 @@ virDomainGetCPUStats(virDomainPtr domain, virCheckNullArgGoto(params, error); if (nparams && ncpus > UINT_MAX / nparams) { - virLibDomainError(VIR_ERR_OVERFLOW, _("input too large: %u * %u"), - nparams, ncpus); + virReportError(VIR_ERR_OVERFLOW, _("input too large: %u * %u"), + nparams, ncpus); goto error; } if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, -- 1.8.4.2

On 12/28/2013 11:11 AM, Eric Blake wrote:
Finish the cleanup; all uses of virLib*Error have now been converted to more canonical conventions.
* src/libvirt.c: Use virReportError in remaining errors. (virLibConnError, virLibDomainError): Delete unused macros. * cfg.mk (msg_gen_function): Drop unused names.
Signed-off-by: Eric Blake <eblake@redhat.com> --- cfg.mk | 10 ---- src/libvirt.c | 158 +++++++++++++++++++++++++++------------------------------- 2 files changed, 74 insertions(+), 94 deletions(-)
For a few less lines create a "virDriverCheckTabMaxReturn()" to replace each of the: if (vir*DriverTabCount >= MAX_DRIVERS) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Too many drivers, cannot register %s"), driver->name); return -1; } ACK John
participants (2)
-
Eric Blake
-
John Ferlan