[libvirt PATCH 0/3] hyperv: return void more often
*** BLURB HERE *** Ján Tomko (3): hyperv: return void from hypervAddSimpleParam hyperv: return void from hypervAddEprParam hyperv: return void from hypervAddEmbeddedParam src/hyperv/hyperv_driver.c | 34 +++++++++++++--------------------- src/hyperv/hyperv_wmi.c | 38 ++++++++++---------------------------- src/hyperv/hyperv_wmi.h | 20 ++++++++++---------- 3 files changed, 33 insertions(+), 59 deletions(-) -- 2.54.0
From: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/hyperv/hyperv_driver.c | 6 ++---- src/hyperv/hyperv_wmi.c | 9 ++------- src/hyperv/hyperv_wmi.h | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 68b2e7fa67..940fa58d0d 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -3739,8 +3739,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset, if (!params) return -1; - if (hypervAddSimpleParam(params, "keyCode", keycodeStr) < 0) - return -1; + hypervAddSimpleParam(params, "keyCode", keycodeStr); if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) return -1; @@ -3759,8 +3758,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset, if (!params) return -1; - if (hypervAddSimpleParam(params, "keyCode", keycodeStr) < 0) - return -1; + hypervAddSimpleParam(params, "keyCode", keycodeStr); if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) return -1; diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 1e39e6d61f..ab3eb5ffc0 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -204,10 +204,8 @@ hypervCheckParams(hypervInvokeParamsList *params) * * Add a param of type HYPERV_SIMPLE_PARAM, which is essentially a serialized * key/value pair. - * - * Returns -1 on failure, 0 on success. */ -int +void hypervAddSimpleParam(hypervInvokeParamsList *params, const char *name, const char *value) { @@ -222,8 +220,6 @@ hypervAddSimpleParam(hypervInvokeParamsList *params, const char *name, p->simple.value = value; params->nbParams++; - - return 0; } @@ -1672,8 +1668,7 @@ hypervImageManagementServiceGetVHDSD(hypervPrivate *priv, params = hypervCreateInvokeParamsList("GetVirtualHardDiskSettingData", MSVM_IMAGEMANAGEMENTSERVICE_SELECTOR, Msvm_ImageManagementService_WmiInfo); - if (hypervAddSimpleParam(params, "Path", vhdPath) < 0) - return -1; + hypervAddSimpleParam(params, "Path", vhdPath); if (hypervInvokeMethod(priv, ¶ms, &response) < 0) return -1; diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 36ca85a592..706fd85e87 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -141,8 +141,8 @@ hypervInvokeParamsList *hypervCreateInvokeParamsList(const char *method, void hypervFreeInvokeParams(hypervInvokeParamsList *params); G_DEFINE_AUTOPTR_CLEANUP_FUNC(hypervInvokeParamsList, hypervFreeInvokeParams); -int hypervAddSimpleParam(hypervInvokeParamsList *params, const char *name, - const char *value); +void hypervAddSimpleParam(hypervInvokeParamsList *params, const char *name, + const char *value); int hypervAddEprParam(hypervInvokeParamsList *params, const char *name, -- 2.54.0
From: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/hyperv/hyperv_driver.c | 13 +++++-------- src/hyperv/hyperv_wmi.c | 11 ++++------- src/hyperv/hyperv_wmi.h | 8 ++++---- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 940fa58d0d..52e2ac111c 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -2968,8 +2968,7 @@ hypervDomainUndefineFlags(virDomainPtr domain, unsigned int flags) virBufferEscapeSQL(&eprQuery, MSVM_COMPUTERSYSTEM_WQL_SELECT "WHERE Name = '%s'", uuid_string); - if (hypervAddEprParam(params, "AffectedSystem", &eprQuery, Msvm_ComputerSystem_WmiInfo) < 0) - return -1; + hypervAddEprParam(params, "AffectedSystem", &eprQuery, Msvm_ComputerSystem_WmiInfo); /* actually destroy the VM */ if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) @@ -4238,9 +4237,8 @@ hypervDomainSnapshotCreateXML(virDomainPtr domain, if (!params) return NULL; - if (hypervAddEprParam(params, "AffectedSystem", &eprQuery, - Msvm_ComputerSystem_WmiInfo) < 0) - return NULL; + hypervAddEprParam(params, "AffectedSystem", &eprQuery, + Msvm_ComputerSystem_WmiInfo); snapshotSettings = hypervCreateEmbeddedParam(Msvm_VirtualSystemSnapshotSettingData_WmiInfo); if (!snapshotSettings) @@ -4304,9 +4302,8 @@ hypervDomainSnapshotDelete(virDomainSnapshotPtr snapshot, if (!params) return -1; - if (hypervAddEprParam(params, "AffectedSnapshot", &eprQuery, - Msvm_VirtualSystemSettingData_WmiInfo) < 0) - return -1; + hypervAddEprParam(params, "AffectedSnapshot", &eprQuery, + Msvm_VirtualSystemSettingData_WmiInfo); /* Invoke the method */ if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index ab3eb5ffc0..30ff81d83e 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -231,9 +231,9 @@ hypervAddSimpleParam(hypervInvokeParamsList *params, const char *name, * @query: WQL filter * @eprInfo: WmiInfo of the object being filtered * - * Adds an EPR param to the params list. Returns -1 on failure, 0 on success. + * Adds an EPR param to the params list. */ -int +void hypervAddEprParam(hypervInvokeParamsList *params, const char *name, virBuffer *query, @@ -249,8 +249,6 @@ hypervAddEprParam(hypervInvokeParamsList *params, p->epr.query = query; p->epr.info = classInfo; params->nbParams++; - - return 0; } @@ -1730,9 +1728,8 @@ hypervMsvmVSMSAddResourceSettings(virDomainPtr domain, if (!params) return -1; - if (hypervAddEprParam(params, "AffectedConfiguration", - &eprQuery, Msvm_VirtualSystemSettingData_WmiInfo) < 0) - return -1; + hypervAddEprParam(params, "AffectedConfiguration", + &eprQuery, Msvm_VirtualSystemSettingData_WmiInfo); if (hypervAddEmbeddedParam(params, "ResourceSettings", &resourceSettings, wmiInfo) < 0) { hypervFreeEmbeddedParam(resourceSettings); diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 706fd85e87..c769ac4db0 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -144,10 +144,10 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(hypervInvokeParamsList, hypervFreeInvokeParams); void hypervAddSimpleParam(hypervInvokeParamsList *params, const char *name, const char *value); -int hypervAddEprParam(hypervInvokeParamsList *params, - const char *name, - virBuffer *query, - hypervWmiClassInfo *eprInfo); +void hypervAddEprParam(hypervInvokeParamsList *params, + const char *name, + virBuffer *query, + hypervWmiClassInfo *eprInfo); GHashTable *hypervCreateEmbeddedParam(hypervWmiClassInfo *info); -- 2.54.0
From: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/hyperv/hyperv_driver.c | 15 ++++++--------- src/hyperv/hyperv_wmi.c | 18 ++++-------------- src/hyperv/hyperv_wmi.h | 8 ++++---- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 52e2ac111c..50b4c88939 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -3054,9 +3054,8 @@ hypervDomainDefineXMLFlags(virConnectPtr conn, } } - if (hypervAddEmbeddedParam(params, "SystemSettings", - &defineSystemParam, Msvm_VirtualSystemSettingData_WmiInfo) < 0) - goto error; + hypervAddEmbeddedParam(params, "SystemSettings", + &defineSystemParam, Msvm_VirtualSystemSettingData_WmiInfo); /* create the VM */ if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) @@ -3312,9 +3311,8 @@ hypervDomainSetAutostart(virDomainPtr domain, int autostart) if (hypervSetEmbeddedProperty(autostartParam, "InstanceID", vssd->data->InstanceID) < 0) return -1; - if (hypervAddEmbeddedParam(params, "SystemSettings", - &autostartParam, Msvm_VirtualSystemSettingData_WmiInfo) < 0) - return -1; + hypervAddEmbeddedParam(params, "SystemSettings", + &autostartParam, Msvm_VirtualSystemSettingData_WmiInfo); if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) return -1; @@ -4250,9 +4248,8 @@ hypervDomainSnapshotCreateXML(virDomainPtr domain, HYPERV_SNAPSHOT_CONSISTENCY_CRASH_CONSISTENT) < 0) return NULL; - if (hypervAddEmbeddedParam(params, "SnapshotSettings", &snapshotSettings, - Msvm_VirtualSystemSnapshotSettingData_WmiInfo) < 0) - return NULL; + hypervAddEmbeddedParam(params, "SnapshotSettings", &snapshotSettings, + Msvm_VirtualSystemSnapshotSettingData_WmiInfo); hypervAddSimpleParam(params, "SnapshotType", HYPERV_SNAPSHOT_TYPE_FULL); diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 30ff81d83e..c669ecd8f9 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -314,11 +314,9 @@ hypervSetEmbeddedProperty(GHashTable *table, * Add a GHashTable containing object properties as an embedded param to * an invocation list. * - * Upon successful return the @table is consumed and the pointer is cleared out. - * - * Returns -1 on failure, 0 on success. + * Upon return the @table is consumed and the pointer is cleared out. */ -int +void hypervAddEmbeddedParam(hypervInvokeParamsList *params, const char *name, GHashTable **table, @@ -334,8 +332,6 @@ hypervAddEmbeddedParam(hypervInvokeParamsList *params, p->embedded.table = g_steal_pointer(table); p->embedded.info = classInfo; params->nbParams++; - - return 0; } @@ -1731,10 +1727,7 @@ hypervMsvmVSMSAddResourceSettings(virDomainPtr domain, hypervAddEprParam(params, "AffectedConfiguration", &eprQuery, Msvm_VirtualSystemSettingData_WmiInfo); - if (hypervAddEmbeddedParam(params, "ResourceSettings", &resourceSettings, wmiInfo) < 0) { - hypervFreeEmbeddedParam(resourceSettings); - return -1; - } + hypervAddEmbeddedParam(params, "ResourceSettings", &resourceSettings, wmiInfo); if (hypervInvokeMethod(priv, ¶ms, response) < 0) return -1; @@ -1760,10 +1753,7 @@ hypervMsvmVSMSModifyResourceSettings(hypervPrivate *priv, if (!params) return -1; - if (hypervAddEmbeddedParam(params, "ResourceSettings", &resourceSettings, wmiInfo) < 0) { - hypervFreeEmbeddedParam(resourceSettings); - return -1; - } + hypervAddEmbeddedParam(params, "ResourceSettings", &resourceSettings, wmiInfo); if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) return -1; diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index c769ac4db0..c5cd34b411 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -155,10 +155,10 @@ int hypervSetEmbeddedProperty(GHashTable *table, const char *name, const char *value); -int hypervAddEmbeddedParam(hypervInvokeParamsList *params, - const char *name, - GHashTable **table, - hypervWmiClassInfo *info); +void hypervAddEmbeddedParam(hypervInvokeParamsList *params, + const char *name, + GHashTable **table, + hypervWmiClassInfo *info); void hypervFreeEmbeddedParam(GHashTable *p); -- 2.54.0
On Wed, Jun 24, 2026 at 17:36:41 +0200, Ján Tomko via Devel wrote:
*** BLURB HERE ***
Ján Tomko (3): hyperv: return void from hypervAddSimpleParam hyperv: return void from hypervAddEprParam hyperv: return void from hypervAddEmbeddedParam
src/hyperv/hyperv_driver.c | 34 +++++++++++++--------------------- src/hyperv/hyperv_wmi.c | 38 ++++++++++---------------------------- src/hyperv/hyperv_wmi.h | 20 ++++++++++---------- 3 files changed, 33 insertions(+), 59 deletions(-)
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
participants (2)
-
Ján Tomko -
Peter Krempa