public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v3 qemu-server 1/2] dbus-vmstate: introduce dbus_call_method() helper
Date: Wed, 10 Dec 2025 13:57:07 +0100	[thread overview]
Message-ID: <20251210125724.121834-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20251210125724.121834-1-f.ebner@proxmox.com>

Similar to the already existing dbus_get_property() helper, the owner
is respected even if there are multiple (queued) owners on the DBus.

Have the dbus_get_property() helper use the new function to avoid
duplication.

In preparation to fix the call to 'Quit'.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

Changes in v3:
* split patch
* replace dbus_get_property() with a wrapper around dbus_call_method()

 src/PVE/QemuServer/DBusVMState.pm | 39 ++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/src/PVE/QemuServer/DBusVMState.pm b/src/PVE/QemuServer/DBusVMState.pm
index a72d6dd2..05dd1bcd 100644
--- a/src/PVE/QemuServer/DBusVMState.pm
+++ b/src/PVE/QemuServer/DBusVMState.pm
@@ -16,6 +16,30 @@ use constant {
     DBUS_VMSTATE_EXE => '/usr/libexec/qemu-server/dbus-vmstate',
 };
 
+# Call a method for an object from a specific interface name.
+# In contrast to calling the method directly by using $obj->Method(), this
+# actually respects the owner of the object and thus can be used for interfaces
+# with might have multiple (queued) owners on the DBus.
+my sub dbus_call_method {
+    my ($obj, $interface, $method, $params, $timeout) = @_;
+
+    $timeout = 10 if !$timeout;
+
+    my $con = $obj->{service}->get_bus()->get_connection();
+
+    my $call = $con->make_method_call_message(
+        $obj->{service}->get_service_name(),
+        $obj->{object_path},
+        $interface,
+        $method,
+    );
+
+    $call->set_destination($obj->get_service()->get_owner_name());
+    $call->append_args_list($params->@*) if $params;
+
+    return $con->send_with_reply_and_block($call, $timeout * 1000)->get_args_list();
+}
+
 # Retrieves a property from an object from a specific interface name.
 # In contrast to accessing the property directly by using $obj->Property, this
 # actually respects the owner of the object and thus can be used for interfaces
@@ -23,19 +47,8 @@ use constant {
 my sub dbus_get_property {
     my ($obj, $interface, $name) = @_;
 
-    my $con = $obj->{service}->get_bus()->get_connection();
-
-    my $call = $con->make_method_call_message(
-        $obj->{service}->get_service_name(),
-        $obj->{object_path},
-        'org.freedesktop.DBus.Properties',
-        'Get',
-    );
-
-    $call->set_destination($obj->get_service()->get_owner_name());
-    $call->append_args_list($interface, $name);
-
-    my @reply = $con->send_with_reply_and_block($call, 10 * 1000)->get_args_list();
+    my @reply =
+        dbus_call_method($obj, 'org.freedesktop.DBus.Properties', 'Get', [$interface, $name]);
     return $reply[0];
 }
 
-- 
2.47.3



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2025-12-10 12:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-10 12:57 [pve-devel] [PATCH-SERIES v3 qemu-server 0/2] dbus-vmstate: fix method call on dbus object resolving to wrong instance Fiona Ebner
2025-12-10 12:57 ` Fiona Ebner [this message]
2025-12-10 12:57 ` [pve-devel] [PATCH v3 qemu-server 2/2] " Fiona Ebner
2025-12-10 13:28 ` [pve-devel] [PATCH v3 qemu-server 3/3] migrate: remove left-over dbus-vmstate instance when migrating without conntrack state Fiona Ebner
2025-12-10 13:31   ` Fiona Ebner
2025-12-10 14:35 ` [pve-devel] applied: [PATCH-SERIES v3 qemu-server 0/2] dbus-vmstate: fix method call on dbus object resolving to wrong instance Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251210125724.121834-2-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal