From nobody Tue Feb 10 07:40:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1582624626; cv=none; d=zohomail.com; s=zohoarc; b=UT7Zd6U4SQC8rU/j9rpzIPRlVmUgR5hpsOK2rG+9XPFBYhNUSeKboRCRe/KuWUz+xs8PET5qlxuwDMQCwH1MyeAIw6XTonin2QCExQt9DV16uk4s0YFD5vha5cgeLAy5dLIyZNT6KUNMM6tppSb3VXvC3TRJ7tu52pSdYWJV9S0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582624626; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BHcByk/UWp5+E74N3YNxaI7AhlHx8TFK+8XTwvngxwk=; b=B2yJxTFro1Gc+KyHhsFuqM85t2fL/AGCnSyNQ/E2b0Z6eEAMStu10r5i6RrscGC+DWYfWY1vfBueg10Gux+oh2NaKaYNO3wsSzngVZIsgVWDCzUb517FXTHDVifIZoTQs5nZIJIc6k7iMQzV86UsqEiPzz05WSh/TdBlKTS3JZ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1582624626935139.77340383928947; Tue, 25 Feb 2020 01:57:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-PpAIA1DGOeOix_RMFN9B7Q-1; Tue, 25 Feb 2020 04:56:08 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A01EDBA5; Tue, 25 Feb 2020 09:56:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E69B8C072; Tue, 25 Feb 2020 09:56:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 011A7180CB3B; Tue, 25 Feb 2020 09:56:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01P9u0jg027997 for ; Tue, 25 Feb 2020 04:56:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 39A2192962; Tue, 25 Feb 2020 09:56:00 +0000 (UTC) Received: from localhost (unknown [10.48.0.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id E487B92963; Tue, 25 Feb 2020 09:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582624625; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BHcByk/UWp5+E74N3YNxaI7AhlHx8TFK+8XTwvngxwk=; b=VwRYOxgASeE2oMqwxnqS6SpYlyNHGubm/LCgKXa/zVC1+/Z6OgkJi0bY1QkpVOkPNYz9xV MBhnvN8DsGeuJqswV9eN/+WrNzIbETKqKoZzEPouCtRvkJ2SnVzTfRbm0W5FrA1NrUgcJu I61Ge78NYyKd4eT80iclJExQX0O4HLA= X-MC-Unique: PpAIA1DGOeOix_RMFN9B7Q-1 From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Subject: [libvirt PATCH v2 8/9] qemu-slirp: register helper for migration Date: Tue, 25 Feb 2020 10:55:12 +0100 Message-Id: <20200225095513.969053-9-marcandre.lureau@redhat.com> In-Reply-To: <20200225095513.969053-1-marcandre.lureau@redhat.com> References: <20200225095513.969053-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Michal=20Pr=C3=ADvozn=C3=ADk?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau 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=C3=A9 Lureau --- src/qemu/qemu_slirp.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c index 8e001f0d10..e9b23f72a5 100644 --- a/src/qemu/qemu_slirp.c +++ b/src/qemu/qemu_slirp.c @@ -18,6 +18,7 @@ =20 #include =20 +#include "qemu_dbus.h" #include "qemu_extdevice.h" #include "qemu_security.h" #include "qemu_slirp.h" @@ -202,6 +203,16 @@ qemuSlirpGetFD(qemuSlirpPtr slirp) } =20 =20 +static char * +qemuSlirpGetDBusVMStateId(virDomainNetDefPtr net) +{ + char macstr[VIR_MAC_STRING_BUFLEN] =3D ""; + + /* 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 =3D virQEMUDriverGetConfig(driver); + g_autofree char *id =3D qemuSlirpGetDBusVMStateId(net); g_autofree char *pidfile =3D NULL; virErrorPtr orig_err; pid_t pid; int rc; =20 + qemuDBusVMStateRemove(vm, id); + if (!(pidfile =3D qemuSlirpCreatePidFilename(cfg, vm->def, net->info.a= lias))) { VIR_WARN("Unable to construct slirp pidfile path"); return; @@ -310,6 +324,28 @@ qemuSlirpStart(qemuSlirpPtr slirp, } } =20 + if (qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_DBUS_ADDRESS)) { + g_autofree char *id =3D qemuSlirpGetDBusVMStateId(net); + g_autofree char *dbus_addr =3D qemuDBusGetAddress(driver, vm); + + if (qemuDBusStart(driver, vm) < 0) + return -1; + + virCommandAddArgFormat(cmd, "--dbus-id=3D%s", id); + + virCommandAddArgFormat(cmd, "--dbus-address=3D%s", dbus_addr); + + if (qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_MIGRATE)) { + if (qemuDBusVMStateAdd(vm, id) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to register slirp migration")); + return -1; + } + if (incoming) + virCommandAddArg(cmd, "--dbus-incoming"); + } + } + if (qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_EXIT_WITH_PARENT)) virCommandAddArg(cmd, "--exit-with-parent"); =20 --=20 2.25.0.rc2.1.g09a9a1a997