Re: [PATCH 8/8] qemu-slirp: register helper for migration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/14/20 2:46 PM, marcandre.lureau@xxxxxxxxxx wrote:
From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

When the helper supports DBus, connect it to the bus and set its ID.

If the helper supports migration, register its ID to the list of
dbus-vmstate ID to migrate, and specify --dbus-incoming when
restoring the VM.

Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
  src/qemu/qemu_slirp.c | 37 +++++++++++++++++++++++++++++++++++++
  1 file changed, 37 insertions(+)

diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c
index 8e001f0d10..48fc0a68c2 100644
--- a/src/qemu/qemu_slirp.c
+++ b/src/qemu/qemu_slirp.c
@@ -18,6 +18,7 @@
#include <config.h> +#include "qemu_dbus.h"
  #include "qemu_extdevice.h"
  #include "qemu_security.h"
  #include "qemu_slirp.h"
@@ -202,6 +203,16 @@ qemuSlirpGetFD(qemuSlirpPtr slirp)
  }
+static char *
+qemuSlirpGetDBusVMStateId(virDomainNetDefPtr net)
+{
+    char macstr[VIR_MAC_STRING_BUFLEN] = "";
+
+    /* can't use alias, because it's not stable across restarts */
+    return g_strdup_printf("slirp-%s", virMacAddrFormat(&net->mac, macstr));
+}
+
+
  void
  qemuSlirpStop(qemuSlirpPtr slirp,
                virDomainObjPtr vm,
@@ -209,11 +220,14 @@ qemuSlirpStop(qemuSlirpPtr slirp,
                virDomainNetDefPtr net)
  {
      g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
+    g_autofree char *id = qemuSlirpGetDBusVMStateId(net);
      g_autofree char *pidfile = NULL;
      virErrorPtr orig_err;
      pid_t pid;
      int rc;
+ qemuDBusVMStateRemove(vm, id);
+
      if (!(pidfile = qemuSlirpCreatePidFilename(cfg, vm->def, net->info.alias))) {
          VIR_WARN("Unable to construct slirp pidfile path");
          return;
@@ -310,6 +324,29 @@ qemuSlirpStart(qemuSlirpPtr slirp,
          }
      }
+ if (qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_DBUS_ADDRESS)) {
+        g_autofree char *id = qemuSlirpGetDBusVMStateId(net);
+        g_autofree char *dbus_addr = qemuDBusGetAddress(driver, vm);
+
+        if (qemuDBusStart(driver, vm) < 0)
+            return -1;
+
+        virCommandAddArgFormat(cmd, "--dbus-id=%s", id);
+
+        virCommandAddArgFormat(cmd, "--dbus-address=%s", dbus_addr);
+
+        if (qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_MIGRATE)) {
+            if (qemuDBusVMStateAdd(vm, id) < 0) {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("Failed to register slirp migration"));
+                return -1;
+            }
+            if (incoming) {
+                virCommandAddArg(cmd, "--dbus-incoming");
+            }

'make syntax-check' complains here.

Michal





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux