From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569749; cv=none; d=zoho.com; s=zohoarc; b=HVRISxj7dw3W7KPjzijbH4rdVKCEDUR9pgis/Q3iLCt3Ag3mOu3+zuzXx++EFcfsHCaV/JcLo5YV7dz9pNeD7lk5DbfBGjiZUx+8iJ3mM25j5JAhbbTfI7dD4gmVc97zae6WzHcdJvu1g4wfCd9FJ3dDdFIECvUiEXbqDMx+3MQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569749; 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:ARC-Authentication-Results; bh=UcugglpVhgtTdMaDzqy4XmHTQ9OKlhLYiLqhvweaY90=; b=GmH4kGlKH8+6qgf4g7Z+IASbybTwkVq8gOIht9d90OrIBCiE0PoUgya7jUZ/j+n50Xae2K/czXPs98xNusagFpf9hygsF69FuCcbXGf9KIBW5fopqNoZRYwhSjZ2a2Y6HNm68pZiRgEQuBvjCmUHoxk5xLh9ZLvRqBL/6R3hgBI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15625697491091013.7544270113748; Mon, 8 Jul 2019 00:09:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC461883BA; Mon, 8 Jul 2019 07:09:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7786B5DA2E; Mon, 8 Jul 2019 07:09:03 +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 1910241F66; Mon, 8 Jul 2019 07:09:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6878DC7006587 for ; Mon, 8 Jul 2019 03:08:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 348DB1972D; Mon, 8 Jul 2019 07:08:13 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3EB419739; Mon, 8 Jul 2019 07:08:04 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:25 +0400 Message-Id: <20190708070747.1962-2-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 01/23] Add .editorconfig 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 08 Jul 2019 07:09:04 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Consistent code style across editors. Signed-off-by: Marc-Andr=C3=A9 Lureau --- .editorconfig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..e766441a50 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig is a file format and collection of text editor plugins +# for maintaining consistent coding styles between different editors +# and IDEs. Most popular editors support this either natively or via +# plugin. +# +# Check https://editorconfig.org for details. + +root =3D true + +[*] +end_of_line =3D lf +insert_final_newline =3D true +charset =3D utf-8 + +[*.c] +indent_style =3D space +indent_size =3D 4 + +[*.{rng,xml}] +indent_style =3D space +indent_size =3D 2 --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569759; cv=none; d=zoho.com; s=zohoarc; b=ocyZwmYPlnLITyu1wzE7wNZjCjxlm1cMPX9kBAcdadG+6IsR5qXe5hBPs2GeXNyhUWRnnI2VU6QB2O+RN6cYkpDAF6O/ngvgLi/R+x+o9OKEdmdACtlyo+A9ixAMDMleOEiGL5DAjG/OK3kCQ1S9or0PWshcE7P1zGP2BdEsbLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569759; 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:ARC-Authentication-Results; bh=KDgrbS3A60xz3DreGets4ub9mvFLEPHIcn1okU31j8A=; b=IZhfOBBAi6Bo8Zl/VN8semhDK19Zyg1Bcu5x/vBxNeby8+z6Tj+UKONFq+TTCnHpGkZoAbYmHKxMQo9kT1Yu+uPpH762c21Ywe2DtK6aMI7M/F+/oHnltUhnUGUdLdFddTFy+gLx4ZHLrw9Zs13bauoGwplVES6qk2Wnt4lvAxk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156256975915820.026088119864767; Mon, 8 Jul 2019 00:09:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 212F310F6F; Mon, 8 Jul 2019 07:09:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED98D5DA34; Mon, 8 Jul 2019 07:09:16 +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 ABCA9C59A; Mon, 8 Jul 2019 07:09:16 +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 x6878Oup006601 for ; Mon, 8 Jul 2019 03:08:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E08739C5; Mon, 8 Jul 2019 07:08:24 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC2422FC41; Mon, 8 Jul 2019 07:08:18 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:26 +0400 Message-Id: <20190708070747.1962-3-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-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: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 02/23] dbus: correctly build reply message 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 08 Jul 2019 07:09:17 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau dbus_message_new() does not construct correct replies by itself, it is recommended to use dbus_message_new_method_return() instead. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/util/virdbus.c | 18 ++++++++++++------ src/util/virdbus.h | 6 ++++-- tests/virfirewalltest.c | 9 ++++++--- tests/virpolkittest.c | 3 ++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/util/virdbus.c b/src/util/virdbus.c index b0ac8d7055..64513eef14 100644 --- a/src/util/virdbus.c +++ b/src/util/virdbus.c @@ -1456,6 +1456,7 @@ int virDBusCreateMethod(DBusMessage **call, =20 /** * virDBusCreateReplyV: + * @msg: the message to reply to * @reply: pointer to be filled with a method reply message * @types: type signature for following method arguments * @args: method arguments @@ -1468,13 +1469,14 @@ int virDBusCreateMethod(DBusMessage **call, * as variadic args. See virDBusCreateMethodV for a * description of this parameter. */ -int virDBusCreateReplyV(DBusMessage **reply, +int virDBusCreateReplyV(DBusMessage *msg, + DBusMessage **reply, const char *types, va_list args) { int ret =3D -1; =20 - if (!(*reply =3D dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN))) { + if (!(*reply =3D dbus_message_new_method_return(msg))) { virReportOOMError(); goto cleanup; } @@ -1493,6 +1495,7 @@ int virDBusCreateReplyV(DBusMessage **reply, =20 /** * virDBusCreateReply: + * @msg: the message to reply to * @reply: pointer to be filled with a method reply message * @types: type signature for following method arguments * @...: method arguments @@ -1500,14 +1503,15 @@ int virDBusCreateReplyV(DBusMessage **reply, * See virDBusCreateReplyV for a description of the * behaviour of this method. */ -int virDBusCreateReply(DBusMessage **reply, +int virDBusCreateReply(DBusMessage *msg, + DBusMessage **reply, const char *types, ...) { va_list args; int ret; =20 va_start(args, types); - ret =3D virDBusCreateReplyV(reply, types, args); + ret =3D virDBusCreateReplyV(msg, reply, types, args); va_end(args); =20 return ret; @@ -1811,7 +1815,8 @@ int virDBusCreateMethodV(DBusMessage **call ATTRIBUTE= _UNUSED, return -1; } =20 -int virDBusCreateReplyV(DBusMessage **reply ATTRIBUTE_UNUSED, +int virDBusCreateReplyV(DBusMessage *msg ATTRIBUTE_UNUSED, + DBusMessage **reply ATTRIBUTE_UNUSED, const char *types ATTRIBUTE_UNUSED, va_list args ATTRIBUTE_UNUSED) { @@ -1820,7 +1825,8 @@ int virDBusCreateReplyV(DBusMessage **reply ATTRIBUTE= _UNUSED, return -1; } =20 -int virDBusCreateReply(DBusMessage **reply ATTRIBUTE_UNUSED, +int virDBusCreateReply(DBusMessage *msg ATTRIBUTE_UNUSED, + DBusMessage **reply ATTRIBUTE_UNUSED, const char *types ATTRIBUTE_UNUSED, ...) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/util/virdbus.h b/src/util/virdbus.h index 083c074d59..0303e91045 100644 --- a/src/util/virdbus.h +++ b/src/util/virdbus.h @@ -52,9 +52,11 @@ int virDBusCreateMethodV(DBusMessage **call, const char *member, const char *types, va_list args); -int virDBusCreateReply(DBusMessage **reply, +int virDBusCreateReply(DBusMessage *msg, + DBusMessage **reply, const char *types, ...); -int virDBusCreateReplyV(DBusMessage **reply, +int virDBusCreateReplyV(DBusMessage *msg, + DBusMessage **reply, const char *types, va_list args); =20 diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c index 7c586877d3..d2c85a27cc 100644 --- a/tests/virfirewalltest.c +++ b/tests/virfirewalltest.c @@ -150,7 +150,8 @@ VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_= and_block, if (nargs =3D=3D 1 && STREQ(type, "ipv4") && STREQ(args[0], "-L")) { - if (virDBusCreateReply(&reply, + if (virDBusCreateReply(message, + &reply, "s", TEST_FILTER_TABLE_LIST) < 0) goto error; } else if (nargs =3D=3D 3 && @@ -158,11 +159,13 @@ VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_repl= y_and_block, STREQ(args[0], "-t") && STREQ(args[1], "nat") && STREQ(args[2], "-L")) { - if (virDBusCreateReply(&reply, + if (virDBusCreateReply(message, + &reply, "s", TEST_NAT_TABLE_LIST) < 0) goto error; } else { - if (virDBusCreateReply(&reply, + if (virDBusCreateReply(message, + &reply, "s", "success") < 0) goto error; } diff --git a/tests/virpolkittest.c b/tests/virpolkittest.c index 94a6daae0c..598eca8803 100644 --- a/tests/virpolkittest.c +++ b/tests/virpolkittest.c @@ -123,7 +123,8 @@ VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_= and_block, VIR_FREE(cancellationId); virStringListFreeCount(details, detailslen); =20 - if (virDBusCreateReply(&reply, + if (virDBusCreateReply(message, + &reply, "(bba&{ss})", is_authorized, is_challenge, --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569728; cv=none; d=zoho.com; s=zohoarc; b=TEwx3QQbnDB+P89X0uoyDTgw+SnCHy4PnIRMyFKmZSbHAMA5ueQKWX6va41TnNBheSsKArVMEq8/axHaTqJh5G5Ryug3aZCAIzV79bQdto11qgBHFPxOEYKIQSNYkCpocYqI5LhwzNPZDREu5ua9iObkbQJlF0wPdyPlB3oBCTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569728; 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:ARC-Authentication-Results; bh=AD5Tb00HrvMhMDjyoN6vmSF9AIgHbcWOav8CLNwnICU=; b=NwPujEls17CA9PEZ7pAsYTQf4QYU3yFE5uDtyphEEHB83NVZ+ddnNDgT3YIT4IFlOV4FNlXq4tF1qmwGmgaTbLe0sTQjWhZTd2L8pQgfc3X4GvSjGo/hmV/7xd4GGql7jAGRI6zc6qArAP1f8DNEB/0+shdLKizZlcJhtPX5XqE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569727984645.5216242919604; Mon, 8 Jul 2019 00:08:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6A61F81112; Mon, 8 Jul 2019 07:08:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39CAC57982; Mon, 8 Jul 2019 07:08:36 +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 C6C0254D3C; Mon, 8 Jul 2019 07:08:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6878YJB006620 for ; Mon, 8 Jul 2019 03:08:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id B52A22B9EF; Mon, 8 Jul 2019 07:08:34 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 229452BFA3; Mon, 8 Jul 2019 07:08:28 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:27 +0400 Message-Id: <20190708070747.1962-4-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 03/23] qemu: replace logCtxt with qemuDomainLogAppendMessage() 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 08 Jul 2019 07:08:46 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Once QEMU is started, the qemuDomainLogContext is owned by it, and can no longer be used from libvirt. Instead, use qemuDomainLogAppendMessage() which will redirect the log. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_extdevice.c | 40 ++++++++++++--------------------------- src/qemu/qemu_extdevice.h | 10 +++++----- src/qemu/qemu_process.c | 2 +- src/qemu/qemu_tpm.c | 10 ++++------ src/qemu/qemu_tpm.h | 5 ++--- 5 files changed, 24 insertions(+), 43 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index a21caefaba..79d5d64951 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -36,39 +36,24 @@ VIR_LOG_INIT("qemu.qemu_extdevice"); =20 int -qemuExtDeviceLogCommand(qemuDomainLogContextPtr logCtxt, +qemuExtDeviceLogCommand(virQEMUDriverPtr driver, + virDomainObjPtr vm, virCommandPtr cmd, const char *info) { - int ret =3D -1; - char *timestamp =3D NULL; - char *logline =3D NULL; - int logFD; + VIR_AUTOFREE(char *) timestamp =3D virTimeStringNow(); + VIR_AUTOFREE(char *) cmds =3D virCommandToString(cmd, false); =20 - logFD =3D qemuDomainLogContextGetWriteFD(logCtxt); - - if ((timestamp =3D virTimeStringNow()) =3D=3D NULL) - goto cleanup; - - if (virAsprintf(&logline, "%s: Starting external device: %s\n", - timestamp, info) < 0) - goto cleanup; - - if (safewrite(logFD, logline, strlen(logline)) < 0) - goto cleanup; - - virCommandWriteArgLog(cmd, logFD); - - ret =3D 0; - - cleanup: - VIR_FREE(timestamp); - VIR_FREE(logline); + if (!timestamp || !cmds) + return -1; =20 - return ret; + return qemuDomainLogAppendMessage(driver, vm, + _("%s: Starting external device: %s\= n%s\n"), + timestamp, info, cmds); } =20 =20 + /* * qemuExtDevicesInitPaths: * @@ -127,8 +112,7 @@ qemuExtDevicesCleanupHost(virQEMUDriverPtr driver, =20 int qemuExtDevicesStart(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainLogContextPtr logCtxt) + virDomainObjPtr vm) { int ret =3D 0; =20 @@ -136,7 +120,7 @@ qemuExtDevicesStart(virQEMUDriverPtr driver, return -1; =20 if (vm->def->tpm) - ret =3D qemuExtTPMStart(driver, vm, logCtxt); + ret =3D qemuExtTPMStart(driver, vm); =20 return ret; } diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h index a72e05ce63..c9a3109fb6 100644 --- a/src/qemu/qemu_extdevice.h +++ b/src/qemu/qemu_extdevice.h @@ -23,10 +23,11 @@ #include "qemu_conf.h" #include "qemu_domain.h" =20 -int qemuExtDeviceLogCommand(qemuDomainLogContextPtr logCtxt, +int qemuExtDeviceLogCommand(virQEMUDriverPtr driver, + virDomainObjPtr vm, virCommandPtr cmd, const char *info) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBU= TE_NONNULL(4) ATTRIBUTE_RETURN_CHECK; =20 int qemuExtDevicesPrepareHost(virQEMUDriverPtr driver, @@ -39,9 +40,8 @@ void qemuExtDevicesCleanupHost(virQEMUDriverPtr driver, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 int qemuExtDevicesStart(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainLogContextPtr logCtxt) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) + virDomainObjPtr vm) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; =20 void qemuExtDevicesStop(virQEMUDriverPtr driver, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index aa09ef175a..411ecf17ad 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6705,7 +6705,7 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuProcessGenID(vm, flags) < 0) goto cleanup; =20 - if (qemuExtDevicesStart(driver, vm, logCtxt) < 0) + if (qemuExtDevicesStart(driver, vm) < 0) goto cleanup; =20 VIR_DEBUG("Building emulator command line"); diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index cc8c69433b..200a3d3391 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -754,8 +754,7 @@ qemuExtTPMCleanupHost(virDomainDefPtr def) */ static int qemuExtTPMStartEmulator(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainLogContextPtr logCtxt) + virDomainObjPtr vm) { int ret =3D -1; virCommandPtr cmd =3D NULL; @@ -782,7 +781,7 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver, cfg->swtpmStateDir, shortName)= )) goto cleanup; =20 - if (qemuExtDeviceLogCommand(logCtxt, cmd, "TPM Emulator") < 0) + if (qemuExtDeviceLogCommand(driver, vm, cmd, "TPM Emulator") < 0) goto cleanup; =20 virCommandSetErrorBuffer(cmd, &errbuf); @@ -835,15 +834,14 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver, =20 int qemuExtTPMStart(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainLogContextPtr logCtxt) + virDomainObjPtr vm) { int ret =3D 0; virDomainTPMDefPtr tpm =3D vm->def->tpm; =20 switch (tpm->type) { case VIR_DOMAIN_TPM_TYPE_EMULATOR: - ret =3D qemuExtTPMStartEmulator(driver, vm, logCtxt); + ret =3D qemuExtTPMStartEmulator(driver, vm); break; case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: case VIR_DOMAIN_TPM_TYPE_LAST: diff --git a/src/qemu/qemu_tpm.h b/src/qemu/qemu_tpm.h index 74c9924d68..0be94bac3f 100644 --- a/src/qemu/qemu_tpm.h +++ b/src/qemu/qemu_tpm.h @@ -36,9 +36,8 @@ void qemuExtTPMCleanupHost(virDomainDefPtr def) ATTRIBUTE_NONNULL(1); =20 int qemuExtTPMStart(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainLogContextPtr logCtxt) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) + virDomainObjPtr vm) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; =20 void qemuExtTPMStop(virQEMUDriverPtr driver, --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569728; cv=none; d=zoho.com; s=zohoarc; b=EF4WMpGj/+hXlgQF0fqlR2/1MXAK+iBcZ5f+GCEnl74mPy2dgd2UXdhdyiLSO/D496myUCsub66dJZ6ycpRAWrh1eF+jxj+SvOzU+4w6WEChYUgICTthde7yuzyM0PxyOz8FILEEdqjsmqs9TAwS03I9Tc98ez75v3CGQbTl3DU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569728; 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:ARC-Authentication-Results; bh=c4ZT67zs3t0wdrektL9xjPi3rnnnqgmt50Lc3ol5yFw=; b=bls0FjsmJXoLxPrd3up/ucHTttmymkx9Xx3VXnf+FD4cibNmOkWlskKok8Wq1mEApoqu6l1JfOe5RymnV9LlkKYpysCV+sOfYRvOTZBMpjR8265t8UfoQEmC0ddV7l2txS5K20lWjznEu3icFyHghBo2xxMTmEEA67TQHtDyNrA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569728730507.893482960951; Mon, 8 Jul 2019 00:08:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1148930C34D6; Mon, 8 Jul 2019 07:08:42 +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 DBB4617D48; Mon, 8 Jul 2019 07:08:40 +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 9EC5F1833002; Mon, 8 Jul 2019 07:08:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6878d5w006630 for ; Mon, 8 Jul 2019 03:08:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id B61205C46B; Mon, 8 Jul 2019 07:08:39 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id D85202BFC4; Mon, 8 Jul 2019 07:08:38 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:28 +0400 Message-Id: <20190708070747.1962-5-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 04/23] qemu: reset VM id after external devices stop 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 08 Jul 2019 07:08:42 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau pid filenames (from swtpm and other helpers from this series) are based on VM shortname, which is derived from VM id. If the id is reset to early, the state filenames will not be found. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 411ecf17ad..5156b4906c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7324,8 +7324,6 @@ void qemuProcessStop(virQEMUDriverPtr driver, =20 qemuProcessBuildDestroyMemoryPaths(driver, vm, NULL, false); =20 - vm->def->id =3D -1; - if (virAtomicIntDecAndTest(&driver->nactive) && driver->inhibitCallbac= k) driver->inhibitCallback(false, driver->inhibitOpaque); =20 @@ -7401,6 +7399,8 @@ void qemuProcessStop(virQEMUDriverPtr driver, =20 qemuExtDevicesStop(driver, vm); =20 + vm->def->id =3D -1; + /* Stop autodestroy in case guest is restarted */ qemuProcessAutoDestroyRemove(driver, vm); =20 --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569749; cv=none; d=zoho.com; s=zohoarc; b=krLnod+1GmMtn3E0Vr1oNVpc9KhATw/DVFIZBKMea5AhvIwfTPBjGyxPB5mvIujR3ZRqPgXbmG6upjFJ1O+n+BtRL8xOJ4AwQsHbe+TR2MRluE7HaHQSo/egS9EqR/1OSIlAbo+NNke6M0NUTB+ZIQGbaou4Q/5g66EupShYyoA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569749; 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:ARC-Authentication-Results; bh=C+WjKLqo9RqcBlOBtXgYm+TPcT+Nw7SLlpJnNcUuq/A=; b=BbnvZnLtNEXJfMUp55zrVjELSBJEBLEKcMgp0aHDwgBmZ62QSxTx1XLhgvBrac81gpSRx1dc9xJyGr0boBG2iE2SmVmaGrFERtSytfA7ZNUT73EmiJXvUQ3MFV8ztEkJdEYnn4OkYPsHgsDWEg9gHgOP3dbecKHRdsugVAEGSAw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569749451925.8087940931066; Mon, 8 Jul 2019 00:09:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5074E2E95B0; Mon, 8 Jul 2019 07:09:05 +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 1911E5C22F; Mon, 8 Jul 2019 07:09:05 +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 AF4C81833004; Mon, 8 Jul 2019 07:09:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6878rEB006642 for ; Mon, 8 Jul 2019 03:08:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3DE3C19C77; Mon, 8 Jul 2019 07:08:53 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id C482919730; Mon, 8 Jul 2019 07:08:44 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:29 +0400 Message-Id: <20190708070747.1962-6-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 05/23] qemu: add socket datagram capability 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 08 Jul 2019 07:09:06 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Datagram socket is available since qemu 4.0, commit fdec16e3c2a614e2861f3086b05d444b5d8c3406 ("net/socket: learn to talk with a unix dgram socket"). Required for slirp-helper communication. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_capabilities.c | 8 ++++++++ src/qemu/qemu_capabilities.h | 3 +++ tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml | 1 + 9 files changed, 18 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 02e84edc15..2229aea4f5 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -533,6 +533,9 @@ VIR_ENUM_IMPL(virQEMUCaps, "x86-max-cpu", "cpu-unavailable-features", "canonical-cpu-features", + + /* 335 */ + "net-socket-dgram", ); =20 =20 @@ -4373,6 +4376,11 @@ virQEMUCapsInitQMPVersionCaps(virQEMUCapsPtr qemuCap= s) ARCH_IS_PPC64(qemuCaps->arch)) { virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT); } + + /* -net socket,fd=3D with dgram socket (for ex, with slirp helper) */ + if (qemuCaps->version >=3D 3001092) { + virQEMUCapsSet(qemuCaps, QEMU_CAPS_NET_SOCKET_DGRAM); + } } =20 =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 915ba6cb2e..564e3bfe55 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -515,6 +515,9 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_CPU_UNAVAILABLE_FEATURES, /* "unavailable-features" CPU prop= erty */ QEMU_CAPS_CANONICAL_CPU_FEATURES, /* avoid CPU feature aliases */ =20 + /* 335 */ + QEMU_CAPS_NET_SOCKET_DGRAM, /* -net socket,fd=3D with dgram socket */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; =20 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_4.0.0.aarch64.xml index 250b7edd52..a0846b0782 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml @@ -163,6 +163,7 @@ + 4000000 0 61700758 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_4.0.0.ppc64.xml index 24b55002a6..6ebf003f51 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml @@ -168,6 +168,7 @@ + 4000000 0 42900758 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml b/tests/qemu= capabilitiesdata/caps_4.0.0.riscv32.xml index 230e1e7c99..8ba9e41dae 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml @@ -166,6 +166,7 @@ + 4000000 0 0 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml b/tests/qemu= capabilitiesdata/caps_4.0.0.riscv64.xml index 4b2f4cf628..dd0e1ca6f6 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml @@ -166,6 +166,7 @@ + 4000000 0 0 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_4.0.0.s390x.xml index a1ac2587a0..9c50b1afdf 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml @@ -131,6 +131,7 @@ + 4000000 0 39100758 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_4.0.0.x86_64.xml index 716b756979..cd2f74b219 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -205,6 +205,7 @@ + 4000000 0 43100758 diff --git a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_4.1.0.x86_64.xml index 9cbf65b405..ca1d7dbbfe 100644 --- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml @@ -207,6 +207,7 @@ + 4000050 0 43100759 --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569759; cv=none; d=zoho.com; s=zohoarc; b=gv9yn1n8RBa4pjrwF38Te4E+KKIDWCHWoDgkTIoE9kY9ppvEjnIIh5NlZIXPCh0ZPXliq8a1q0JjokaCoKrrYW3r0QEyzMtVhq2cQHJpAI2mk7GUBgm0rdqJiUEfP9lUtnWcgKTTMi97DlhMuWc8J4peX5E/ABVJ70phX9QM3gE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569759; 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:ARC-Authentication-Results; bh=UxCJeJzVcLW94GLG+ago7DosprIb6q+Ypy3pBXgFWAo=; b=i0eGk5fTnbxiRug0TSKEmz8AMqJBIu1im3gVfR0negRAgmtPzD+Xp6z2jlHQBweXbCXZJ5IZGKA+5DQhrp6o8P550+jycWy6LzQ62BgEI8fWAbfPL7LGC0p2IZa7moSSEvZPC3dm9cGJZXGqt9LBbtYlLnBZRvzpj8+STmcNqqo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569759088361.476767943868; Mon, 8 Jul 2019 00:09:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27BE030860B1; Mon, 8 Jul 2019 07:09:17 +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 F40E51001B35; Mon, 8 Jul 2019 07:09:16 +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 B53A51833008; Mon, 8 Jul 2019 07:09:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x68794VN006659 for ; Mon, 8 Jul 2019 03:09:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2FD5A2B1C1; Mon, 8 Jul 2019 07:09:04 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id E16992B1A5; Mon, 8 Jul 2019 07:08:57 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:30 +0400 Message-Id: <20190708070747.1962-7-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 06/23] qemu: add dbus-vmstate capability 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 08 Jul 2019 07:09:17 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau This object is being proposed to qemu upstream "Add dbus-vmstate object". It handles data migration of external processes. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2229aea4f5..9e6390af52 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -536,6 +536,7 @@ VIR_ENUM_IMPL(virQEMUCaps, =20 /* 335 */ "net-socket-dgram", + "dbus-vmstate", ); =20 =20 @@ -1124,6 +1125,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[= ] =3D { { "virtio-serial-pci-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL = }, { "virtio-serial-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIO= NAL }, { "max-x86_64-cpu", QEMU_CAPS_X86_MAX_CPU }, + { "dbus-vmstate", QEMU_CAPS_DBUS_VMSTATE }, }; =20 static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[]= =3D { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 564e3bfe55..d71198802b 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -517,6 +517,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ =20 /* 335 */ QEMU_CAPS_NET_SOCKET_DGRAM, /* -net socket,fd=3D with dgram socket */ + QEMU_CAPS_DBUS_VMSTATE, /* -object dbus-vmstate */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569768; cv=none; d=zoho.com; s=zohoarc; b=A9JSnot1CHf9kpFfa8Jsboz/O22KtPtIsoXVZohlDzlgQHVGIhHIcspBafgu4yOun6GuWTmTqIdR7Auymtmp/ZkgrhrvBZ6kWwaP0vPTuXebF7AkGFY8p1O8EuB1Bou2cI35GYO/gn1h4RF30o/oDtBijdwC+HJZDRrVOTp6RHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569768; 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:ARC-Authentication-Results; bh=2BRH2NSR8+1Dx2hxPeIgXhszgQA9FWU0TA5FS+TMX5U=; b=UTHJ0tks3kA9Pkdz0G6eiNA9BrO1OnJJ45Fn4p+DlgNrn1P3tUfC4gjtqymJoy9U6GyRiGNAEr5meIBwoDiVuGsnCFjiLdLbURy8zOYDOtDluuJDQgoCCoSjS9oPkq20PdUh7R7NlCwQctSIwdSWrOyJDeIBJaOdcg3yeMPZahY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569768360446.08765269427533; Mon, 8 Jul 2019 00:09:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BFB033001442; Mon, 8 Jul 2019 07:09:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 95CE019936; Mon, 8 Jul 2019 07:09:26 +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 512C38E1F; Mon, 8 Jul 2019 07:09:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6879EeU006671 for ; Mon, 8 Jul 2019 03:09:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7229B54577; Mon, 8 Jul 2019 07:09:14 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BFBD53C30; Mon, 8 Jul 2019 07:09:08 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:31 +0400 Message-Id: <20190708070747.1962-8-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 07/23] qemu-conf: add configurable dbus-daemon location 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 08 Jul 2019 07:09:27 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- m4/virt-driver-qemu.m4 | 5 +++++ src/qemu/libvirtd_qemu.aug | 1 + src/qemu/qemu.conf | 3 +++ src/qemu/qemu_conf.c | 7 ++++++- src/qemu/qemu_conf.h | 1 + src/qemu/test_libvirtd_qemu.aug.in | 1 + 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/m4/virt-driver-qemu.m4 b/m4/virt-driver-qemu.m4 index a1d05bbd7f..1bc1755620 100644 --- a/m4/virt-driver-qemu.m4 +++ b/m4/virt-driver-qemu.m4 @@ -105,6 +105,11 @@ AC_DEFUN([LIBVIRT_DRIVER_CHECK_QEMU], [ [/usr/bin:/usr/libexec]) AC_DEFINE_UNQUOTED([QEMU_PR_HELPER], ["$QEMU_PR_HELPER"], [QEMU PR helper]) + AC_PATH_PROG([QEMU_DBUS_DAEMON], [dbus-daemon], + [/usr/bin/dbus-daemon], + [/usr/bin:/usr/libexec]) + AC_DEFINE_UNQUOTED([QEMU_DBUS_DAEMON], ["$QEMU_DBUS_DAEMON"], + [QEMU dbus daemon]) ]) =20 AC_DEFUN([LIBVIRT_DRIVER_RESULT_QEMU], [ diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index eea9094d39..ba4caabc42 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -89,6 +89,7 @@ module Libvirtd_qemu =3D | bool_entry "clear_emulator_capabilities" | str_entry "bridge_helper" | str_entry "pr_helper" + | str_entry "dbus_daemon" | bool_entry "set_process_name" | int_entry "max_processes" | int_entry "max_files" diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index fd2ed9dc21..26bab39123 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -823,6 +823,9 @@ # used whenever are enabled for SCSI LUN devices. #pr_helper =3D "/usr/bin/qemu-pr-helper" =20 +# Path to the dbus-daemon +#dbus_daemon =3D "/usr/bin/dbus-daemon" + # User for the swtpm TPM Emulator # # Default is 'tss'; this is the same user that tcsd (TrouSerS) installs diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index e0195dac29..6f15ce2086 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -278,7 +278,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool priv= ileged) } =20 if (VIR_STRDUP(cfg->bridgeHelperName, QEMU_BRIDGE_HELPER) < 0 || - VIR_STRDUP(cfg->prHelperName, QEMU_PR_HELPER) < 0) + VIR_STRDUP(cfg->prHelperName, QEMU_PR_HELPER) < 0 || + VIR_STRDUP(cfg->dbusDaemonName, QEMU_DBUS_DAEMON) < 0) goto error; =20 cfg->clearEmulatorCapabilities =3D true; @@ -368,6 +369,7 @@ static void virQEMUDriverConfigDispose(void *obj) VIR_FREE(cfg->hugetlbfs); VIR_FREE(cfg->bridgeHelperName); VIR_FREE(cfg->prHelperName); + VIR_FREE(cfg->dbusDaemonName); =20 VIR_FREE(cfg->saveImageFormat); VIR_FREE(cfg->dumpImageFormat); @@ -664,6 +666,9 @@ virQEMUDriverConfigLoadProcessEntry(virQEMUDriverConfig= Ptr cfg, if (virConfGetValueString(conf, "pr_helper", &cfg->prHelperName) < 0) return -1; =20 + if (virConfGetValueString(conf, "dbus_daemon", &cfg->dbusDaemonName) <= 0) + return -1; + if (virConfGetValueBool(conf, "set_process_name", &cfg->setProcessName= ) < 0) return -1; if (virConfGetValueUInt(conf, "max_processes", &cfg->maxProcesses) < 0) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index e51514a344..0799846001 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -151,6 +151,7 @@ struct _virQEMUDriverConfig { =20 char *bridgeHelperName; char *prHelperName; + char *dbusDaemonName; =20 bool macFilter; =20 diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qe= mu.aug.in index 388ba24b8b..e135869717 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -103,6 +103,7 @@ module Test_libvirtd_qemu =3D } { "memory_backing_dir" =3D "/var/lib/libvirt/qemu/ram" } { "pr_helper" =3D "/usr/bin/qemu-pr-helper" } +{ "dbus_daemon" =3D "/usr/bin/dbus-daemon" } { "swtpm_user" =3D "tss" } { "swtpm_group" =3D "tss" } { "capability_filters" --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569769; cv=none; d=zoho.com; s=zohoarc; b=LM17eWwOUmrQzLU52v/LS0WIFhwkgS5E98GEKWSn2lTpbCOGbPIArJrTkaxXq6cM0VK0qRODahQioTkXGY6oaaA8T53ySe05jbU9R26AlRlzQIkJYnhG1h5yc5+2d8Y/leaXa9coWmeS3IKuHemdfaK9gqlLyjmDHU34y8gL0YI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569769; 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:ARC-Authentication-Results; bh=EAIGoFE/J03oyGaOUk668zA1vvKp+On7Lcr1qAwEBaU=; b=e/TcrXnYS0LuZZ1m9JLD4xA+wSoIAElqK5rSqYxRU2yYk8yUAwqRsjvU5g3mUxCuwGwyoeOC8IpLAV4eEqwsdVF1kilpJEVj6shAk2oeLXZcgrrr4WJDGmp/rvVEsS7px6RXukV5K60E7icE337cXX5SPAVaEDpvZOybnRtxOxQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569769964494.7908138695025; Mon, 8 Jul 2019 00:09:29 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 2B72D81E0A; Mon, 8 Jul 2019 07:09:28 +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 09A872C01D; Mon, 8 Jul 2019 07:09:28 +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 BF10A1833007; Mon, 8 Jul 2019 07:09:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6879QY2006690 for ; Mon, 8 Jul 2019 03:09:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA542BAB1; Mon, 8 Jul 2019 07:09:26 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D3ADBA7C; Mon, 8 Jul 2019 07:09:18 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:32 +0400 Message-Id: <20190708070747.1962-9-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 08/23] qemu-conf: add dbusStateDir 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 08 Jul 2019 07:09:28 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Location of DBus daemon state configuration, socket, pid... Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_conf.c | 8 ++++++++ src/qemu/qemu_conf.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 6f15ce2086..5f6f93d828 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -149,6 +149,10 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool pri= vileged) "%s/run/libvirt/qemu/swtpm", LOCALSTATEDIR) < 0) goto error; =20 + if (virAsprintf(&cfg->dbusStateDir, + "%s/run/libvirt/qemu/dbus", LOCALSTATEDIR) < 0) + goto error; + if (virAsprintf(&cfg->cacheDir, "%s/cache/libvirt/qemu", LOCALSTATEDIR) < 0) goto error; @@ -214,6 +218,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool priv= ileged) if (virAsprintf(&cfg->swtpmStateDir, "%s/swtpm", cfg->stateDir) < = 0) goto error; =20 + if (virAsprintf(&cfg->dbusStateDir, "%s/dbus", cfg->stateDir) < 0) + goto error; + if (!(cfg->configBaseDir =3D virGetUserConfigDirectory())) goto error; =20 @@ -331,6 +338,7 @@ static void virQEMUDriverConfigDispose(void *obj) VIR_FREE(cfg->swtpmLogDir); VIR_FREE(cfg->stateDir); VIR_FREE(cfg->swtpmStateDir); + VIR_FREE(cfg->dbusStateDir); =20 VIR_FREE(cfg->libDir); VIR_FREE(cfg->cacheDir); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 0799846001..c87cb8bc41 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -95,6 +95,7 @@ struct _virQEMUDriverConfig { char *swtpmLogDir; char *stateDir; char *swtpmStateDir; + char *dbusStateDir; /* These two directories are ones QEMU processes use (so must match * the QEMU user/group */ char *libDir; --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569779; cv=none; d=zoho.com; s=zohoarc; b=al2KPF6LHPuVKRJa/wm3srZauVhjRw4anAZ7vVR+Afo5NhvF6+lkae0hK7Poev++ZZBa0JGratYKDZKwLWsxxhC+miOWBZ6Qmw8TvVzrZ5xthHVBdXW9GzgQlviQVKR+CHGKh2E0QzB5BOGNnlLOQLQbGCv/7ZP+0JxVKn8O6Ok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569779; 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:ARC-Authentication-Results; bh=tRgidBiYtFjKu4hU6JzYa7x4LW2Qtz6hTyLd4xJPl+s=; b=LxKpZh0MrO4jO/iosY1E3h7AfhlXYRDKvENkEf3DgTmNlCpxRbDulyaPhlIEdjOcpBlVdwTv0kY8RjAwFO4XY5OZBlDuNxFzHlucEsGRw8JU0c+FADP52mfQ1PhbX7DYVQIIgg9ZifPjDVbWvXrSfdGEvTC6t1JHGvdb0n363Ak= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156256977999021.174108234227674; Mon, 8 Jul 2019 00:09:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5249C99C4B; Mon, 8 Jul 2019 07:09:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2BE595DA2E; Mon, 8 Jul 2019 07:09:38 +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 E5C94206D4; Mon, 8 Jul 2019 07:09:37 +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 x6879a95006725 for ; Mon, 8 Jul 2019 03:09:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7682217D40; Mon, 8 Jul 2019 07:09:36 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0837317D4B; Mon, 8 Jul 2019 07:09:30 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:33 +0400 Message-Id: <20190708070747.1962-10-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-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: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 09/23] qemu-security: add qemuSecurityCommandRun() 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 08 Jul 2019 07:09:38 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Add a generic way to run a command through the security management. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_security.c | 22 ++++++++++++++++++++++ src/qemu/qemu_security.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c index 87209d3781..f9aa94e0a7 100644 --- a/src/qemu/qemu_security.c +++ b/src/qemu/qemu_security.c @@ -631,3 +631,25 @@ qemuSecurityRestoreSavedStateLabel(virQEMUDriverPtr dr= iver, virSecurityManagerTransactionAbort(driver->securityManager); return ret; } + + +int +qemuSecurityCommandRun(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virCommandPtr cmd, + int *exitstatus, + int *cmdret) +{ + if (virSecurityManagerSetChildProcessLabel(driver->securityManager, + vm->def, cmd) < 0) + return -1; + + if (virSecurityManagerPreFork(driver->securityManager) < 0) + return -1; + + *cmdret =3D virCommandRun(cmd, exitstatus); + + virSecurityManagerPostFork(driver->securityManager); + + return 0; +} diff --git a/src/qemu/qemu_security.h b/src/qemu/qemu_security.h index 68e377f418..8cf4ab0721 100644 --- a/src/qemu/qemu_security.h +++ b/src/qemu/qemu_security.h @@ -101,6 +101,12 @@ int qemuSecurityRestoreSavedStateLabel(virQEMUDriverPt= r driver, virDomainObjPtr vm, const char *savefile); =20 +int qemuSecurityCommandRun(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virCommandPtr cmd, + int *exitstatus, + int *cmdret); + /* Please note that for these APIs there is no wrapper yet. Do NOT blindly= add * new APIs here. If an API can touch a file add a proper wrapper instead. */ --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569792; cv=none; d=zoho.com; s=zohoarc; b=G5wWbS7lGlCnF/YGags5q5BHmC+IhqV2K+PsNOaAYnqP9jC3/2XwWGxWle86pxewN2JZiXa+maHYOWh5zwoT8YhQ8ikDxiVpI1HC5QlEJW1P5Df9pHWenfqQM7rpG173KFIGABHVlNNKKnl9budAgbfcZaNLWQi0et1DF24Sqcw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569792; 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:ARC-Authentication-Results; bh=WqDTIGj5QSBRzDVlxOLSyDywCCIN0GIzNYnz4VT/8fc=; b=UGXFVMh/IgOuEex/ce5PHKmrApIFolFJrcyZ+SbchMY6IcSkto4g+EizEnAU9fLN33o/WoEiDK91N6/wDw/ZEURBNQxV2HOgI7cvs7CMDGayyzUcWMa1EulJp2vx81AktQTNbgnoEw7CrcBvu05QjhtQdnqYgvo4UtCZ29aj9yA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569792031146.74255711673197; Mon, 8 Jul 2019 00:09:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7077D5946F; Mon, 8 Jul 2019 07:09:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4CEB053B01; Mon, 8 Jul 2019 07:09:50 +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 0E514206D5; Mon, 8 Jul 2019 07:09:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6879mmu006807 for ; Mon, 8 Jul 2019 03:09:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id D1FCA19C77; Mon, 8 Jul 2019 07:09:48 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA26E1972B; Mon, 8 Jul 2019 07:09:40 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:34 +0400 Message-Id: <20190708070747.1962-11-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 10/23] qemu: add a DBus daemon helper unit 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 08 Jul 2019 07:09:50 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Add a unit to start & stop a private dbus-daemon. The daemon is meant to be started on demand, and associated with a QEMU process. It is stopped when the QEMU process is stopped. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/Makefile.inc.am | 4 + src/qemu/qemu_dbus.c | 370 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_dbus.h | 40 +++++ src/qemu/qemu_domain.c | 10 ++ src/qemu/qemu_domain.h | 5 + src/qemu/qemu_process.c | 6 + tests/Makefile.am | 1 + 7 files changed, 436 insertions(+) create mode 100644 src/qemu/qemu_dbus.c create mode 100644 src/qemu/qemu_dbus.h diff --git a/src/qemu/Makefile.inc.am b/src/qemu/Makefile.inc.am index 254ba07dc0..248f3970c9 100644 --- a/src/qemu/Makefile.inc.am +++ b/src/qemu/Makefile.inc.am @@ -58,6 +58,8 @@ QEMU_DRIVER_SOURCES =3D \ qemu/qemu_qapi.h \ qemu/qemu_tpm.c \ qemu/qemu_tpm.h \ + qemu/qemu_dbus.c \ + qemu/qemu_dbus.h \ $(NULL) =20 =20 @@ -81,6 +83,7 @@ libvirt_driver_qemu_impl_la_CFLAGS =3D \ $(LIBNL_CFLAGS) \ $(SELINUX_CFLAGS) \ $(XDR_CFLAGS) \ + $(DBUS_CFLAGS) \ -I$(srcdir)/access \ -I$(srcdir)/conf \ -I$(srcdir)/secret \ @@ -92,6 +95,7 @@ libvirt_driver_qemu_impl_la_LIBADD =3D \ $(GNUTLS_LIBS) \ $(LIBNL_LIBS) \ $(SELINUX_LIBS) \ + $(DBUS_LIBS) \ $(LIBXML_LIBS) \ $(NULL) libvirt_driver_qemu_impl_la_SOURCES =3D $(QEMU_DRIVER_SOURCES) diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c new file mode 100644 index 0000000000..bf24c85910 --- /dev/null +++ b/src/qemu/qemu_dbus.c @@ -0,0 +1,370 @@ +/* + * qemu_dbus.c: QEMU dbus daemon + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "qemu_extdevice.h" +#include "qemu_dbus.h" +#include "qemu_security.h" + +#include "viralloc.h" +#include "virlog.h" +#include "virstring.h" +#include "virtime.h" +#include "virpidfile.h" + +#define VIR_FROM_THIS VIR_FROM_QEMU + +VIR_LOG_INIT("qemu.dbus"); + + +int +qemuDBusPrepareHost(virQEMUDriverPtr driver) +{ + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + + return virDirCreate(cfg->dbusStateDir, 0770, cfg->user, cfg->group, + VIR_DIR_CREATE_ALLOW_EXIST); +} + + +static char * +qemuDBusCreatePidFilename(const char *stateDir, + const char *shortName) +{ + VIR_AUTOFREE(char *) name =3D NULL; + + if (virAsprintf(&name, "%s-dbus", shortName) < 0) + return NULL; + + return virPidFileBuildPath(stateDir, name); +} + + +static char * +qemuDBusCreateFilename(const char *stateDir, + const char *shortName, + const char *ext) +{ + VIR_AUTOFREE(char *) name =3D NULL; + + if (virAsprintf(&name, "%s-dbus", shortName) < 0) + return NULL; + + return virFileBuildPath(stateDir, name, ext); +} + + +static char * +qemuDBusCreateSocketPath(virQEMUDriverConfigPtr cfg, + const char *shortName) +{ + return qemuDBusCreateFilename(cfg->dbusStateDir, shortName, ".sock"); +} + + +char * +qemuDBusGetAddress(virQEMUDriverPtr driver, + virDomainObjPtr vm) +{ + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + VIR_AUTOFREE(char *) shortName =3D virDomainDefGetShortName(vm->def); + VIR_AUTOFREE(char *) path =3D qemuDBusCreateSocketPath(cfg, shortName); + char *ret; + + ignore_value(virAsprintf(&ret, "unix:path=3D%s", path)); + + return ret; +} + + +static int +qemuDBusGetPid(const char *binPath, + const char *stateDir, + const char *shortName, + pid_t *pid) +{ + VIR_AUTOFREE(char *) pidfile =3D qemuDBusCreatePidFilename(stateDir, s= hortName); + + if (!pidfile) + return -ENOMEM; + + return virPidFileReadPathIfAlive(pidfile, pid, binPath); +} + + +static int +qemuDBusWriteConfig(const char *filename, const char *path) +{ + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + VIR_AUTOFREE(char *) config =3D NULL; + + virBufferAddLit(&buf, "\n"); + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); + + virBufferAddLit(&buf, "org.libvirt.qemu\n"); + + /* This may become useful: */ + /* virBufferAddLit(&buf, "" DATADIR "/dbus-1/libvirt-qemu-= services\n"); */ + + virBufferAsprintf(&buf, "unix:path=3D%s\n", path); + + virBufferAddLit(&buf, "EXTERNAL\n"); + + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); + virBufferAddLit(&buf, "\n"); + virBufferAddLit(&buf, "\n"); + virBufferAddLit(&buf, "\n"); + virBufferAddLit(&buf, "\n"); + virBufferAddLit(&buf, "\n"); + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + + virBufferAddLit(&buf, "contexts/dbus_contexts\n"); + + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + + if (virBufferCheckError(&buf) < 0) + return -1; + + config =3D virBufferContentAndReset(&buf); + + return virFileWriteStr(filename, config, 0600); +} + + +void +qemuDBusStop(virQEMUDriverPtr driver, + virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + VIR_AUTOFREE(char *) shortName =3D NULL; + VIR_AUTOFREE(char *) pidfile =3D NULL; + VIR_AUTOFREE(char *) configfile =3D NULL; + virErrorPtr orig_err; + int rc; + pid_t pid; + + shortName =3D virDomainDefGetShortName(vm->def); + pidfile =3D qemuDBusCreatePidFilename(cfg->dbusStateDir, shortName); + configfile =3D qemuDBusCreateFilename(cfg->dbusStateDir, shortName, ".= conf"); + + if (!shortName || !pidfile || !configfile) + return; + + rc =3D qemuDBusGetPid(cfg->dbusDaemonName, cfg->dbusStateDir, shortNam= e, &pid); + if (rc =3D=3D 0 && pid !=3D (pid_t)-1) { + char ebuf[1024]; + + VIR_DEBUG("Killing dbus-daemon process %lld", (long long)pid); + if (virProcessKill(pid, SIGTERM) < 0 && errno !=3D ESRCH) + VIR_ERROR(_("Failed to kill process %lld: %s"), + (long long)pid, + virStrerror(errno, ebuf, sizeof(ebuf))); + } + + virErrorPreserveLast(&orig_err); + if (virPidFileForceCleanupPath(pidfile) < 0) { + VIR_WARN("Unable to kill dbus-daemon process"); + } else { + if (unlink(pidfile) < 0 && + errno !=3D ENOENT) { + virReportSystemError(errno, + _("Unable to remove stale pidfile %s"), + pidfile); + } + } + if (unlink(configfile) < 0 && + errno !=3D ENOENT) { + virReportSystemError(errno, + _("Unable to remove stale configfile %s"), + pidfile); + } + virErrorRestore(&orig_err); + + VIR_FREE(pidfile); + + priv->dbusDaemonRunning =3D false; +} + + +int +qemuDBusStart(virQEMUDriverPtr driver, + virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + VIR_AUTOPTR(virCommand) cmd =3D NULL; + VIR_AUTOFREE(char *) shortName =3D NULL; + VIR_AUTOFREE(char *) pidfile =3D NULL; + VIR_AUTOFREE(char *) configfile =3D NULL; + VIR_AUTOFREE(char *) sockpath =3D NULL; + virTimeBackOffVar timebackoff; + const unsigned long long timeout =3D 500 * 1000; /* ms */ + int errfd =3D -1; + int cmdret =3D 0; + int exitstatus =3D 0; + + if (priv->dbusDaemonRunning) + return 0; + + /* cleanup */ + qemuDBusStop(driver, vm); + + cmd =3D virCommandNew(cfg->dbusDaemonName); + shortName =3D virDomainDefGetShortName(vm->def); + pidfile =3D qemuDBusCreatePidFilename(cfg->dbusStateDir, shortName); + configfile =3D qemuDBusCreateFilename(cfg->dbusStateDir, shortName, ".= conf"); + sockpath =3D qemuDBusCreateSocketPath(cfg, shortName); + + if (!cmd || !pidfile || !configfile || !sockpath) + return -1; + + if (qemuDBusWriteConfig(configfile, sockpath) < 0) { + virReportSystemError(errno, _("Failed to write '%s'"), configfile); + return -1; + } + + if (qemuSecurityDomainSetPathLabel(driver, vm, configfile, true) < 0) + return -1; + + virCommandClearCaps(cmd); + virCommandSetPidFile(cmd, pidfile); + virCommandSetErrorFD(cmd, &errfd); + virCommandDaemonize(cmd); + virCommandAddArgFormat(cmd, "--config-file=3D%s", configfile); + + if (qemuExtDeviceLogCommand(driver, vm, cmd, "DBus") < 0) + return -1; + + if (qemuSecurityCommandRun(driver, vm, cmd, + &exitstatus, &cmdret) < 0) + return -1; + + if (cmdret < 0 || exitstatus !=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not start 'vhost-user-gpu'. exitstatus: %d= "), + exitstatus); + return -1; + } + + if (virTimeBackOffStart(&timebackoff, 1, timeout) < 0) + return -1; + while (virTimeBackOffWait(&timebackoff)) { + pid_t pid; + + if (qemuDBusGetPid(cfg->dbusDaemonName, cfg->dbusStateDir, shortNa= me, &pid) < 0) + continue; + + if (pid =3D=3D (pid_t)-1) + break; + + if (virFileExists(sockpath)) + break; + } + + if (!virFileExists(sockpath)) { + char errbuf[1024] =3D { 0 }; + + if (saferead(errfd, errbuf, sizeof(errbuf) - 1) < 0) { + virReportSystemError(errno, "%s", _("dbus-daemon died unexpect= edly")); + } else { + virReportError(VIR_ERR_OPERATION_FAILED, + _("dbus-daemon died and reported: %s"), errbuf); + } + + return -1; + } + + if (qemuSecurityDomainSetPathLabel(driver, vm, sockpath, true) < 0) + return -1; + + priv->dbusDaemonRunning =3D true; + + return 0; +} + + +int +qemuDBusSetupCgroup(virQEMUDriverPtr driver, + virDomainDefPtr def, + virCgroupPtr cgroup) +{ + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + VIR_AUTOFREE(char *) shortName =3D virDomainDefGetShortName(def); + pid_t pid; + int rc; + + rc =3D qemuDBusGetPid(cfg->dbusDaemonName, cfg->dbusStateDir, shortNam= e, &pid); + if (rc < 0 || (rc =3D=3D 0 && pid =3D=3D (pid_t)-1)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get process id of dbus-daemon")); + return -1; + } + + if (virCgroupAddProcess(cgroup, pid) < 0) + return -1; + + return 0; +} + + +int +qemuDBusConnect(virQEMUDriverPtr driver, + virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + VIR_AUTOFREE(char *) addr =3D qemuDBusGetAddress(driver, vm); + DBusConnection *conn =3D NULL; + DBusError error; + int ret =3D -1; + + if (!priv->dbusDaemonRunning || priv->dbusConn) + return 0; + + dbus_error_init(&error); + conn =3D dbus_connection_open(addr, &error); + if (!conn) { + virReportError(VIR_ERR_DBUS_SERVICE, _("failed to connect to DBus:= %s"), + error.message ? : _("unknown error")); + goto end; + } + + if (!dbus_bus_register(conn, &error)) { + virReportError(VIR_ERR_DBUS_SERVICE, _("failed to register to DBus= : %s"), + error.message ? : _("unknown error")); + goto end; + } + + priv->dbusConn =3D conn; + conn =3D NULL; + ret =3D 0; + +end: + if (conn) { + dbus_connection_unref(conn); + } + dbus_error_free(&error); + return ret; +} diff --git a/src/qemu/qemu_dbus.h b/src/qemu/qemu_dbus.h new file mode 100644 index 0000000000..8728824bd7 --- /dev/null +++ b/src/qemu/qemu_dbus.h @@ -0,0 +1,40 @@ +/* + * qemu_dbus.h: QEMU dbus daemon + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include "qemu_conf.h" +#include "qemu_domain.h" + +int qemuDBusPrepareHost(virQEMUDriverPtr driver); + +char *qemuDBusGetAddress(virQEMUDriverPtr driver, + virDomainObjPtr vm); + +int qemuDBusConnect(virQEMUDriverPtr driver, + virDomainObjPtr vm); + +int qemuDBusStart(virQEMUDriverPtr driver, + virDomainObjPtr vm); + +void qemuDBusStop(virQEMUDriverPtr driver, + virDomainObjPtr vm); + +int qemuDBusSetupCgroup(virQEMUDriverPtr driver, + virDomainDefPtr def, + virCgroupPtr cgroup); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6225ac23e2..192aceb605 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2051,6 +2051,11 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePt= r priv) =20 qemuDomainObjResetJob(priv); qemuDomainObjResetAsyncJob(priv); + + if (priv->dbusConn) { + dbus_connection_unref(priv->dbusConn); + priv->dbusConn =3D NULL; + } } =20 =20 @@ -2479,6 +2484,9 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, virDomainChrTypeToString(priv->monConfig->type)); } =20 + if (priv->dbusDaemonRunning) + virBufferAddLit(buf, "\n"); + if (priv->namespaces) { ssize_t ns =3D -1; =20 @@ -2910,6 +2918,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, goto error; } =20 + priv->dbusDaemonRunning =3D virXPathBoolean("boolean(./dbusDaemon)", c= txt) > 0; + if ((node =3D virXPathNode("./namespaces", ctxt))) { xmlNodePtr next; =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 3eea8b0f96..9d14163c21 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -39,6 +39,7 @@ #include "logging/log_manager.h" #include "virdomainmomentobjlist.h" #include "virenum.h" +#include "virdbus.h" =20 #define QEMU_DOMAIN_FORMAT_LIVE_FLAGS \ (VIR_DOMAIN_XML_SECURE) @@ -386,6 +387,10 @@ struct _qemuDomainObjPrivate { =20 /* true if global -mem-prealloc appears on cmd line */ bool memPrealloc; + + /* true if dbus-daemon is running */ + bool dbusDaemonRunning; + DBusConnection *dbusConn; }; =20 #define QEMU_DOMAIN_PRIVATE(vm) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5156b4906c..5e8184b0e2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -57,6 +57,7 @@ #include "qemu_security.h" #include "qemu_extdevice.h" #include "qemu_firmware.h" +#include "qemu_dbus.h" =20 #include "cpu/cpu.h" #include "cpu/cpu_x86.h" @@ -6452,6 +6453,9 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv =3D vm->privateData; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); =20 + if (qemuDBusPrepareHost(driver) < 0) + goto cleanup; + if (qemuPrepareNVRAM(cfg, vm) < 0) goto cleanup; =20 @@ -7399,6 +7403,8 @@ void qemuProcessStop(virQEMUDriverPtr driver, =20 qemuExtDevicesStop(driver, vm); =20 + qemuDBusStop(driver, vm); + vm->def->id =3D -1; =20 /* Stop autodestroy in case guest is restarted */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 115afa1c1a..85d0d8f614 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -42,6 +42,7 @@ AM_CFLAGS =3D \ $(APPARMOR_CFLAGS) \ $(YAJL_CFLAGS) \ $(XDR_CFLAGS) \ + $(DBUS_CFLAGS) \ $(WARN_CFLAGS) =20 AM_LDFLAGS =3D \ --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569805; cv=none; d=zoho.com; s=zohoarc; b=Twn8H4biq/88l4m3mSJhRDXFMxoxzbPSPZEWbr5osRMQXG7Y6y8cB5bz9QMAlTF4Qn0ctuHQhQERwZuaA+e+ycz1eStvss1N/Y6uDeq2KisrRYs6wAzuM0BokMzZ8C8xqcj1et9h34Gvdugv9LPl/z5uwPlE7VMT2D6/e5jJ8eY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569805; 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:ARC-Authentication-Results; bh=M2kol0f6YTqbxnM9C8TI4eNOo9XhnYIFAeXGYpxmgk8=; b=ctRhPdZUtaTDkNtnppGhJqLXpJIaQBSWRnF38NggPlI1hvle4MVIqYG5R24zJV0LhqwG9pgjhbeOwcSuyc7cKGrUOcaHrxZpMaIF8fOnC9bMByhO+VPeRK66UFPRKiP83DwdJwtMSwYjT6cmNBKLXxljZn35AOlT9SJSJzm441s= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569805745930.3816666114836; Mon, 8 Jul 2019 00:10:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF7EB308621C; Mon, 8 Jul 2019 07:10:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99CB619744; Mon, 8 Jul 2019 07:10:03 +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 98B8F206D7; Mon, 8 Jul 2019 07:10:02 +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 x687A1G3006836 for ; Mon, 8 Jul 2019 03:10:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0CC44182E6; Mon, 8 Jul 2019 07:10:01 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEEF439C5; Mon, 8 Jul 2019 07:09:54 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:35 +0400 Message-Id: <20190708070747.1962-12-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-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: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 11/23] qemu: add dbus-vmstate helper migration support 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 08 Jul 2019 07:10:04 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Helper processes may have their state migrated with QEMU data stream thanks to the proposed object "dbus-vmstate". libvirt knows what helpers should be migrated. The "dbus-vmstate" is added when required, and given the list of helper Ids that must be present during migration (save & load). See QEMU "Add dbus-vmstate object" patch for further documentation on the helper expected behaviour. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_alias.c | 7 +++ src/qemu/qemu_alias.h | 2 + src/qemu/qemu_command.c | 65 ++++++++++++++++++++++++++++ src/qemu/qemu_command.h | 3 ++ src/qemu/qemu_dbus.c | 14 ++++++ src/qemu/qemu_dbus.h | 4 ++ src/qemu/qemu_domain.c | 8 ++++ src/qemu/qemu_domain.h | 5 +++ src/qemu/qemu_hotplug.c | 82 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_hotplug.h | 8 ++++ src/qemu/qemu_migration.c | 51 ++++++++++++++++++++++ src/qemu/qemu_monitor.c | 22 ++++++++++ src/qemu/qemu_monitor.h | 3 ++ src/qemu/qemu_monitor_json.c | 15 +++++++ src/qemu/qemu_monitor_json.h | 5 +++ 15 files changed, 294 insertions(+) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 585cc972ba..a901932034 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -843,3 +843,10 @@ qemuDomainGetUnmanagedPRAlias(const char *parentalias) =20 return ret; } + + +const char * +qemuDomainGetDBusVMStateAlias(void) +{ + return "dbus-vmstate0"; +} diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h index aaac09a1d1..e3492116c5 100644 --- a/src/qemu/qemu_alias.h +++ b/src/qemu/qemu_alias.h @@ -95,3 +95,5 @@ char *qemuAliasChardevFromDevAlias(const char *devAlias) const char *qemuDomainGetManagedPRAlias(void); =20 char *qemuDomainGetUnmanagedPRAlias(const char *parentalias); + +const char *qemuDomainGetDBusVMStateAlias(void); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 688dc324c6..040e8e2b12 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -24,6 +24,7 @@ #include "qemu_command.h" #include "qemu_hostdev.h" #include "qemu_capabilities.h" +#include "qemu_dbus.h" #include "qemu_interface.h" #include "qemu_alias.h" #include "qemu_security.h" @@ -10406,6 +10407,67 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd, } =20 =20 +static virJSONValuePtr +qemuBuildDBusVMStateInfoPropsInternal(const char *alias, + const char *addr) +{ + virJSONValuePtr ret =3D NULL; + + if (qemuMonitorCreateObjectProps(&ret, + "dbus-vmstate", alias, + "s:addr", addr, NULL) < 0) + return NULL; + + return ret; +} + + +virJSONValuePtr +qemuBuildDBusVMStateInfoProps(virQEMUDriverPtr driver, + virDomainObjPtr vm) +{ + VIR_AUTOFREE(char *) addr =3D qemuDBusGetAddress(driver, vm); + + if (!addr) + return NULL; + + return qemuBuildDBusVMStateInfoPropsInternal(qemuDomainGetDBusVMStateA= lias(), + addr); +} + + +static int +qemuBuildDBusVMStateCommandLine(virCommandPtr cmd, + virQEMUDriverPtr driver, + virDomainObjPtr vm) +{ + VIR_AUTOCLEAN(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + VIR_AUTOPTR(virJSONValue) props =3D NULL; + qemuDomainObjPrivatePtr priv =3D QEMU_DOMAIN_PRIVATE(vm); + + if (virStringListLength((const char **)priv->dbusVMStateIds) =3D=3D 0) + return 0; + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) { + VIR_INFO("dbus-vmstate object is not supported by this QEMU binary= "); + return 0; + } + + if (!(props =3D qemuBuildDBusVMStateInfoProps(driver, vm))) + return -1; + + if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0) + return -1; + + virCommandAddArg(cmd, "-object"); + virCommandAddArgBuffer(cmd, &buf); + + priv->dbusVMState =3D true; + + return 0; +} + + /** * qemuBuildCommandLineValidate: * @@ -10650,6 +10712,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildMasterKeyCommandLine(cmd, priv) < 0) goto error; =20 + if (qemuBuildDBusVMStateCommandLine(cmd, driver, vm) < 0) + goto error; + if (qemuBuildManagedPRCommandLine(cmd, def, priv) < 0) goto error; =20 diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 8695832c16..8bb941e2bc 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -58,6 +58,9 @@ virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr drive= r, virJSONValuePtr qemuBuildPRManagerInfoProps(virStorageSourcePtr src); virJSONValuePtr qemuBuildPRManagedManagerInfoProps(qemuDomainObjPrivatePtr= priv); =20 +virJSONValuePtr qemuBuildDBusVMStateInfoProps(virQEMUDriverPtr driver, + virDomainObjPtr vm); + /* Generate the object properties for a secret */ int qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo, virJSONValuePtr *propsret); diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c index bf24c85910..729be09069 100644 --- a/src/qemu/qemu_dbus.c +++ b/src/qemu/qemu_dbus.c @@ -368,3 +368,17 @@ end: dbus_error_free(&error); return ret; } + + +int +qemuDBusVMStateAdd(virDomainObjPtr vm, const char *id) +{ + return virStringListAdd(&QEMU_DOMAIN_PRIVATE(vm)->dbusVMStateIds, id); +} + + +void +qemuDBusVMStateRemove(virDomainObjPtr vm, const char *id) +{ + virStringListRemove(&QEMU_DOMAIN_PRIVATE(vm)->dbusVMStateIds, id); +} diff --git a/src/qemu/qemu_dbus.h b/src/qemu/qemu_dbus.h index 8728824bd7..e86134b2a1 100644 --- a/src/qemu/qemu_dbus.h +++ b/src/qemu/qemu_dbus.h @@ -38,3 +38,7 @@ void qemuDBusStop(virQEMUDriverPtr driver, int qemuDBusSetupCgroup(virQEMUDriverPtr driver, virDomainDefPtr def, virCgroupPtr cgroup); + +int qemuDBusVMStateAdd(virDomainObjPtr vm, const char *id); + +void qemuDBusVMStateRemove(virDomainObjPtr vm, const char *id); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 192aceb605..b7fcaab186 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2056,6 +2056,9 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr= priv) dbus_connection_unref(priv->dbusConn); priv->dbusConn =3D NULL; } + + virStringListFree(priv->dbusVMStateIds); + priv->dbusVMStateIds =3D NULL; } =20 =20 @@ -2487,6 +2490,9 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, if (priv->dbusDaemonRunning) virBufferAddLit(buf, "\n"); =20 + if (priv->dbusVMState) + virBufferAddLit(buf, "\n"); + if (priv->namespaces) { ssize_t ns =3D -1; =20 @@ -2920,6 +2926,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, =20 priv->dbusDaemonRunning =3D virXPathBoolean("boolean(./dbusDaemon)", c= txt) > 0; =20 + priv->dbusVMState =3D virXPathBoolean("boolean(./dbusVMState)", ctxt) = > 0; + if ((node =3D virXPathNode("./namespaces", ctxt))) { xmlNodePtr next; =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 9d14163c21..20c5fbec09 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -391,6 +391,11 @@ struct _qemuDomainObjPrivate { /* true if dbus-daemon is running */ bool dbusDaemonRunning; DBusConnection *dbusConn; + + /* list of Ids to migrate */ + char **dbusVMStateIds; + /* true if -object dbus-vmstate was added */ + bool dbusVMState; }; =20 #define QEMU_DOMAIN_PRIVATE(vm) \ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 7e9c1a1649..ccff9a79d7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -325,6 +325,88 @@ qemuDomainChangeMediaLegacy(virQEMUDriverPtr driver, } =20 =20 +/** + * qemuHotplugAttachDBusVMState: + * @driver: QEMU driver object + * @vm: domain object + * @asyncJob: asynchronous job identifier + * + * Add -object dbus-vmstate if necessary. + * + * Returns: 0 on success, -1 on error. + */ +int +qemuHotplugAttachDBusVMState(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + VIR_AUTOPTR(virJSONValue) props =3D NULL; + int ret; + + if (priv->dbusVMState) + return 0; + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) { + VIR_INFO("dbus-vmstate object is not supported by this QEMU binary= "); + return 0; + } + + if (!(props =3D qemuBuildDBusVMStateInfoProps(driver, vm))) + return -1; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + ret =3D qemuMonitorAddObject(priv->mon, &props, NULL); + + if (ret =3D=3D 0) + priv->dbusVMState =3D true; + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + return -1; + + return ret; +} + + +/** + * qemuHotplugRemoveDBusVMState: + * @driver: QEMU driver object + * @vm: domain object + * @asyncJob: asynchronous job identifier + * + * Remove -object dbus-vmstate from @vm if the configuration does not requ= ire + * it any more. + * + * Returns: 0 on success, -1 on error. + */ +int +qemuHotplugRemoveDBusVMState(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + int ret; + + if (!priv->dbusVMState) + return 0; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + ret =3D qemuMonitorDelObject(priv->mon, qemuDomainGetDBusVMStateAlias(= )); + + if (ret =3D=3D 0) + priv->dbusVMState =3D false; + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + return -1; + + return ret; +} + + /** * qemuHotplugAttachManagedPR: * @driver: QEMU driver object diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 896e6c7b98..10896976be 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -150,3 +150,11 @@ int qemuDomainSetVcpuInternal(virQEMUDriverPtr driver, virDomainDefPtr persistentDef, virBitmapPtr vcpus, bool state); + +int qemuHotplugAttachDBusVMState(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob); + +int qemuHotplugRemoveDBusVMState(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 2436f5051b..a11c6f1a9f 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1112,10 +1112,18 @@ qemuMigrationSrcIsAllowed(virQEMUDriverPtr driver, bool remote, unsigned int flags) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; int nsnapshots; int pauseReason; size_t i; =20 + if (virStringListLength((const char **)priv->dbusVMStateIds) && + !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot migrate this domain without dbus-vmstate = support")); + return false; + } + /* perform these checks only when migrating to remote hosts */ if (remote) { nsnapshots =3D virDomainSnapshotObjListNum(vm->snapshots, NULL, 0); @@ -1846,8 +1854,14 @@ qemuMigrationDstRun(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; =20 + rv =3D qemuMonitorSetDBusVMStateIdList(priv->mon, + (const char **)priv->dbusVMStateI= ds); + if (rv < 0) + goto exit_monitor; + rv =3D qemuMonitorMigrateIncoming(priv->mon, uri); =20 + exit_monitor: if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0) goto cleanup; =20 @@ -3352,6 +3366,37 @@ qemuMigrationSrcContinue(virQEMUDriverPtr driver, } =20 =20 +static int +qemuMigrationSetDBusVMState(virQEMUDriverPtr driver, + virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + if (virStringListLength((const char **)priv->dbusVMStateIds) > 0) { + int rv; + + if (qemuHotplugAttachDBusVMState(driver, vm, QEMU_ASYNC_JOB_NONE) = < 0) + return -1; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, QEMU_ASYNC_JOB_NONE= ) < 0) + return -1; + + rv =3D qemuMonitorSetDBusVMStateIdList(priv->mon, + (const char **)priv->dbusVMSt= ateIds); + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + rv =3D -1; + + return rv; + } else { + if (qemuHotplugRemoveDBusVMState(driver, vm, QEMU_ASYNC_JOB_NONE) = < 0) + return -1; + } + + return 0; +} + + static int qemuMigrationSrcRun(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3502,6 +3547,9 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, } } =20 + if (qemuMigrationSetDBusVMState(driver, vm) < 0) + goto exit_monitor; + /* Before EnterMonitor, since already qemuProcessStopCPUs does that */ if (!(flags & VIR_MIGRATE_LIVE) && virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { @@ -5207,6 +5255,9 @@ qemuMigrationSrcToFile(virQEMUDriverPtr driver, virDo= mainObjPtr vm, char *errbuf =3D NULL; virErrorPtr orig_err =3D NULL; =20 + if (qemuMigrationSetDBusVMState(driver, vm) < 0) + return -1; + /* Increase migration bandwidth to unlimited since target is a file. * Failure to change migration speed is not fatal. */ if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) =3D=3D 0) { diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 731be2e5a6..ea57bad9f5 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -27,6 +27,7 @@ #include #include =20 +#include "qemu_alias.h" #include "qemu_monitor.h" #include "qemu_monitor_text.h" #include "qemu_monitor_json.h" @@ -2478,6 +2479,27 @@ qemuMonitorSavePhysicalMemory(qemuMonitorPtr mon, } =20 =20 +int +qemuMonitorSetDBusVMStateIdList(qemuMonitorPtr mon, + const char **list) +{ + VIR_AUTOFREE(char *) path =3D NULL; + + VIR_DEBUG("list=3D%p", list); + + if (virStringListLength(list) =3D=3D 0) + return 0; + + if (virAsprintf(&path, "/objects/%s", + qemuDomainGetDBusVMStateAlias()) < 0) + return -1; + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONSetDBusVMStateIdList(mon, path, list); +} + + int qemuMonitorSetMigrationSpeed(qemuMonitorPtr mon, unsigned long bandwidth) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index c41428b048..fcb029f97f 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -685,6 +685,9 @@ int qemuMonitorSavePhysicalMemory(qemuMonitorPtr mon, size_t length, const char *path); =20 +int qemuMonitorSetDBusVMStateIdList(qemuMonitorPtr mon, + const char **list); + int qemuMonitorSetMigrationSpeed(qemuMonitorPtr mon, unsigned long bandwidth); =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8723ff49c7..239005dbad 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2304,6 +2304,21 @@ qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitorPtr m= on, } =20 =20 +int +qemuMonitorJSONSetDBusVMStateIdList(qemuMonitorPtr mon, + const char *vmstatepath, + const char **list) +{ + VIR_AUTOFREE(char *) str =3D virStringListJoin(list, ","); + qemuMonitorJSONObjectProperty prop =3D { + .type =3D QEMU_MONITOR_OBJECT_PROPERTY_STRING, + .val.str =3D str, + }; + + return qemuMonitorJSONSetObjectProperty(mon, vmstatepath, "id-list", &= prop); +} + + /* qemuMonitorJSONQueryBlock: * @mon: Monitor pointer * diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index d0b519c88e..1ed2b005e4 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -605,3 +605,8 @@ int qemuMonitorJSONMergeBitmaps(qemuMonitorPtr mon, int qemuMonitorJSONDeleteBitmap(qemuMonitorPtr mon, const char *node, const char *bitmap); + +int qemuMonitorJSONSetDBusVMStateIdList(qemuMonitorPtr mon, + const char *vmstatepath, + const char **list) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569817; cv=none; d=zoho.com; s=zohoarc; b=RvLTbSVUg0jSXHKtdUGDR7re9U0ZprzgyIRhZrPULkoqdhk/Nbc5qUurEKIlPJTu5cFMkrfaewG37hffgEb8Gorjb0pjHKF6gy9hQ2gZhtn2UAur7bXOfTBGwW8Yh025esQmO0MHAVMa5svzfz6n7fFCgM1xapo2jsYf+fqpDuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569817; 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:ARC-Authentication-Results; bh=pgf1kq+f4N6LriHp4Hu1haKitZkfjrTbanX4l1BjIcY=; b=XYQ4CtK5kcbXyCxVtSV9EE+WY90X6tzQsAyUzIS/lUx52yzHEUz+hmbxfTY2VBpF5lwSUHYDmcTW5AhSyOJ85LIlFmupOvk2DO0HwCmrEnE+zD4qS0qgdYC6FY8FDknJzh48eyR2c5emFIE+iES9yD8xA1KrvWxZvccaj6ItwBo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156256981735644.69679482810534; Mon, 8 Jul 2019 00:10:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B586F30BD1B3; Mon, 8 Jul 2019 07:10:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 849FA51966; Mon, 8 Jul 2019 07:10:15 +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 28BA4206D7; Mon, 8 Jul 2019 07:10:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x687AD8j006880 for ; Mon, 8 Jul 2019 03:10:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id B53C32B9EF; Mon, 8 Jul 2019 07:10:13 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA4FD2C152; Mon, 8 Jul 2019 07:10:05 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:36 +0400 Message-Id: <20190708070747.1962-13-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 12/23] domain-conf: add network def private data 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 08 Jul 2019 07:10:16 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/conf/domain_conf.c | 21 ++++++++++++++++++++- src/conf/domain_conf.h | 6 ++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3323c9a5b1..9e868b5337 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2451,6 +2451,7 @@ virDomainNetDefFree(virDomainNetDefPtr def) if (!def) return; virDomainNetDefClear(def); + virObjectUnref(def->privateData); VIR_FREE(def); } =20 @@ -11434,7 +11435,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, VIR_AUTOFREE(char *) trustGuestRxFilters =3D NULL; VIR_AUTOFREE(char *) vhost_path =3D NULL; =20 - if (VIR_ALLOC(def) < 0) + if (!(def =3D virDomainNetDefNew(xmlopt))) return NULL; =20 ctxt->node =3D node; @@ -14312,6 +14313,24 @@ virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlo= pt) } =20 =20 +virDomainNetDefPtr +virDomainNetDefNew(virDomainXMLOptionPtr xmlopt) +{ + virDomainNetDefPtr def =3D NULL; + + if (VIR_ALLOC(def) < 0) + return NULL; + + if (xmlopt && xmlopt->privateData.networkNew && + !(def->privateData =3D xmlopt->privateData.networkNew())) { + VIR_FREE(def); + def =3D NULL; + } + + return def; +} + + /* Parse the XML definition for a graphics device */ static virDomainGraphicsDefPtr virDomainGraphicsDefParseXML(virDomainXMLOptionPtr xmlopt, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c1b5fc1337..ebe9ac183e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1019,6 +1019,7 @@ struct _virDomainNetDef { unsigned int mtu; virNetDevCoalescePtr coalesce; virDomainVirtioOptionsPtr virtio; + virObjectPtr privateData; }; =20 typedef enum { @@ -2708,6 +2709,7 @@ struct _virDomainXMLPrivateDataCallbacks { virDomainXMLPrivateDataNewFunc chrSourceNew; virDomainXMLPrivateDataNewFunc vsockNew; virDomainXMLPrivateDataNewFunc graphicsNew; + virDomainXMLPrivateDataNewFunc networkNew; virDomainXMLPrivateDataFormatFunc format; virDomainXMLPrivateDataParseFunc parse; /* following function shall return a pointer which will be used as the @@ -2891,6 +2893,10 @@ virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOp= tionPtr xmlopt); =20 virDomainGraphicsDefPtr virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlopt); + +virDomainNetDefPtr +virDomainNetDefNew(virDomainXMLOptionPtr xmlopt); + virDomainDefPtr virDomainDefNew(void); =20 void virDomainObjAssignDef(virDomainObjPtr domain, --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569828; cv=none; d=zoho.com; s=zohoarc; b=j49KiLLEISND8lTl69PJEYJTvC7+1TcmJ/4lJ+IsyVlAV1/7AppyjsqkYEgeerjQ1527NY4Ya9bqXvYDdTu9d5nsKiyyTxewLjH63hyyxAj8a26/FRGh0a3GyMP/9J5pBhiZtZVSJFbCkHMq2yLzZLO1gUF4ETt4EwuS3xuriQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569828; 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:ARC-Authentication-Results; bh=bs8xvz4vUis7qMsjMOBODogfLKNyde2txK3vZqTiY4w=; b=B3aJ2ah1JOYMKdJBtkKM3m0Fxbx6oVxkcqZ6DIHvJNlt0uEiw4fYnJHHZAb/f4i6PKrJdrbkkR5U0SCZ9/rjMvyFgL1K3+cePBH3jCYaj6soaxcpCZtbvxjJfrs3ymryw+vyeDznwnqGcI9QTYkYYHvMK1acoBNSS0fjA4HM8Tg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156256982835168.1735986972543; Mon, 8 Jul 2019 00:10:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C36423086217; Mon, 8 Jul 2019 07:10:26 +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 9241057988; Mon, 8 Jul 2019 07:10:26 +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 56A591833002; Mon, 8 Jul 2019 07:10:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x687AOuU006931 for ; Mon, 8 Jul 2019 03:10:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id C701057982; Mon, 8 Jul 2019 07:10:24 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 283D553CE6; Mon, 8 Jul 2019 07:10:18 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:37 +0400 Message-Id: <20190708070747.1962-14-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 13/23] qemu: add qemuDomainNetworkPrivate 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 08 Jul 2019 07:10:27 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_domain.c | 39 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 12 ++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b7fcaab186..825c23aa26 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1272,6 +1272,44 @@ qemuDomainGraphicsPrivateDispose(void *obj) } =20 =20 +static virClassPtr qemuDomainNetworkPrivateClass; +static void qemuDomainNetworkPrivateDispose(void *obj); + + +static int +qemuDomainNetworkPrivateOnceInit(void) +{ + if (!VIR_CLASS_NEW(qemuDomainNetworkPrivate, virClassForObject())) + return -1; + + return 0; +} + + +VIR_ONCE_GLOBAL_INIT(qemuDomainNetworkPrivate); + + +static virObjectPtr +qemuDomainNetworkPrivateNew(void) +{ + qemuDomainNetworkPrivatePtr priv; + + if (qemuDomainNetworkPrivateInitialize() < 0) + return NULL; + + if (!(priv =3D virObjectNew(qemuDomainNetworkPrivateClass))) + return NULL; + + return (virObjectPtr) priv; +} + + +static void +qemuDomainNetworkPrivateDispose(void *obj ATTRIBUTE_UNUSED) +{ +} + + /* qemuDomainSecretPlainSetup: * @secinfo: Pointer to secret info * @usageType: The virSecretUsageType @@ -3089,6 +3127,7 @@ virDomainXMLPrivateDataCallbacks virQEMUDriverPrivate= DataCallbacks =3D { .chrSourceNew =3D qemuDomainChrSourcePrivateNew, .vsockNew =3D qemuDomainVsockPrivateNew, .graphicsNew =3D qemuDomainGraphicsPrivateNew, + .networkNew =3D qemuDomainNetworkPrivateNew, .parse =3D qemuDomainObjPrivateXMLParse, .format =3D qemuDomainObjPrivateXMLFormat, .getParseOpaque =3D qemuDomainObjPrivateXMLGetParseOpaque, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 20c5fbec09..7ab44d3c43 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -511,6 +511,18 @@ struct _qemuDomainGraphicsPrivate { }; =20 =20 +#define QEMU_DOMAIN_NETWORK_PRIVATE(dev) \ + ((qemuDomainNetworkPrivatePtr) (dev)->privateData) + +typedef struct _qemuDomainNetworkPrivate qemuDomainNetworkPrivate; +typedef qemuDomainNetworkPrivate *qemuDomainNetworkPrivatePtr; +struct _qemuDomainNetworkPrivate { + virObject parent; + + bool tmp_to_be_larger_than_parent; +}; + + typedef enum { QEMU_PROCESS_EVENT_WATCHDOG =3D 0, QEMU_PROCESS_EVENT_GUESTPANIC, --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569840; cv=none; d=zoho.com; s=zohoarc; b=K9h/uZlCrlMNSvVOM0JlVsy4Hd95Z8u78mHeHFS1DlMRUQ9qNY+wSDDSMPrBAggdWECSsr7PZMUODHdGgXTtvLsuppZwxRM/rnuC+EjWp3RI37ZUrndeVB3D/p93kdFYohtAvIn7nk2GEIcHHsPsoalPoNdxza+haUSgWVT/nGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569840; 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:ARC-Authentication-Results; bh=Hc4k1Zgoq7aFJDX52C6vcnkf31azcM+BtZ6YUrmDVyw=; b=K+lZiCvb3uZoX70peAX56j55BDiCothMfgzbp2Bcqv5S2e9DnKLUdJCc683/kO62V6sZtum3JRAGpkZ6h9FS4sMGaTI2Mm8/aoJGmp5h6pMOdxJ/vLRZ9zZw4wq8I/eOGIfXsyfLh5SyvMLBlc5HPngjZUd+9cEEPoEI6fNxjt0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569840255980.6031835185877; Mon, 8 Jul 2019 00:10:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B08D03082211; Mon, 8 Jul 2019 07:10:38 +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 8CBC2BA7C; Mon, 8 Jul 2019 07:10:38 +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 54F131833005; Mon, 8 Jul 2019 07:10:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x687AZLT006953 for ; Mon, 8 Jul 2019 03:10:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id D5E2E5DA2E; Mon, 8 Jul 2019 07:10:35 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DCF55D9E5; Mon, 8 Jul 2019 07:10:29 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:38 +0400 Message-Id: <20190708070747.1962-15-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 14/23] qemu-conf: add configurable slirp-helper location 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 08 Jul 2019 07:10:39 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau A slirp helper is a process that provides user-mode networking through a unix domain socket. It is expected to follow the following specification: https://gitlab.freedesktop.org/slirp/libslirp-rs/blob/master/src/bin/README= .rst Signed-off-by: Marc-Andr=C3=A9 Lureau --- m4/virt-driver-qemu.m4 | 5 +++++ src/qemu/libvirtd_qemu.aug | 1 + src/qemu/qemu.conf | 3 +++ src/qemu/qemu_conf.c | 5 +++++ src/qemu/qemu_conf.h | 1 + src/qemu/test_libvirtd_qemu.aug.in | 1 + 6 files changed, 16 insertions(+) diff --git a/m4/virt-driver-qemu.m4 b/m4/virt-driver-qemu.m4 index 1bc1755620..b050411b7b 100644 --- a/m4/virt-driver-qemu.m4 +++ b/m4/virt-driver-qemu.m4 @@ -110,6 +110,11 @@ AC_DEFUN([LIBVIRT_DRIVER_CHECK_QEMU], [ [/usr/bin:/usr/libexec]) AC_DEFINE_UNQUOTED([QEMU_DBUS_DAEMON], ["$QEMU_DBUS_DAEMON"], [QEMU dbus daemon]) + AC_PATH_PROG([QEMU_SLIRP_HELPER], [slirp-helper], + [/usr/bin/slirp-helper], + [/usr/bin:/usr/libexec]) + AC_DEFINE_UNQUOTED([QEMU_SLIRP_HELPER], ["$QEMU_SLIRP_HELPER"], + [QEMU slirp helper]) ]) =20 AC_DEFUN([LIBVIRT_DRIVER_RESULT_QEMU], [ diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index ba4caabc42..e989fa8623 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -90,6 +90,7 @@ module Libvirtd_qemu =3D | str_entry "bridge_helper" | str_entry "pr_helper" | str_entry "dbus_daemon" + | str_entry "slirp_helper" | bool_entry "set_process_name" | int_entry "max_processes" | int_entry "max_files" diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index 26bab39123..b8408b2f79 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -823,6 +823,9 @@ # used whenever are enabled for SCSI LUN devices. #pr_helper =3D "/usr/bin/qemu-pr-helper" =20 +# Path to the SLIRP networking helper. +#slirp_helper =3D "/usr/bin/slirp-helper" + # Path to the dbus-daemon #dbus_daemon =3D "/usr/bin/dbus-daemon" =20 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 5f6f93d828..a986feecea 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -286,6 +286,7 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool priv= ileged) =20 if (VIR_STRDUP(cfg->bridgeHelperName, QEMU_BRIDGE_HELPER) < 0 || VIR_STRDUP(cfg->prHelperName, QEMU_PR_HELPER) < 0 || + VIR_STRDUP(cfg->slirpHelperName, QEMU_SLIRP_HELPER) < 0 || VIR_STRDUP(cfg->dbusDaemonName, QEMU_DBUS_DAEMON) < 0) goto error; =20 @@ -377,6 +378,7 @@ static void virQEMUDriverConfigDispose(void *obj) VIR_FREE(cfg->hugetlbfs); VIR_FREE(cfg->bridgeHelperName); VIR_FREE(cfg->prHelperName); + VIR_FREE(cfg->slirpHelperName); VIR_FREE(cfg->dbusDaemonName); =20 VIR_FREE(cfg->saveImageFormat); @@ -674,6 +676,9 @@ virQEMUDriverConfigLoadProcessEntry(virQEMUDriverConfig= Ptr cfg, if (virConfGetValueString(conf, "pr_helper", &cfg->prHelperName) < 0) return -1; =20 + if (virConfGetValueString(conf, "slirp_helper", &cfg->slirpHelperName)= < 0) + return -1; + if (virConfGetValueString(conf, "dbus_daemon", &cfg->dbusDaemonName) <= 0) return -1; =20 diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index c87cb8bc41..003851d2a7 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -153,6 +153,7 @@ struct _virQEMUDriverConfig { char *bridgeHelperName; char *prHelperName; char *dbusDaemonName; + char *slirpHelperName; =20 bool macFilter; =20 diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qe= mu.aug.in index e135869717..1bb3de3edc 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -103,6 +103,7 @@ module Test_libvirtd_qemu =3D } { "memory_backing_dir" =3D "/var/lib/libvirt/qemu/ram" } { "pr_helper" =3D "/usr/bin/qemu-pr-helper" } +{ "slirp_helper" =3D "/usr/bin/slirp-helper" } { "dbus_daemon" =3D "/usr/bin/dbus-daemon" } { "swtpm_user" =3D "tss" } { "swtpm_group" =3D "tss" } --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569850; cv=none; d=zoho.com; s=zohoarc; b=HH2XPCukLNQM6eRATtdmaps52SkkPHA+zw3BMHEOL0coyK33HSATyhXK/ahMzdIUXl6tM/GnwBTfE4Q4H3cn45L1wEyIV47jOBBzAJ2bvoO2MuiTctAnNFXouFGvzjbxgnI+pL+c/UNuR6X/1wLLNNNyOZePhcvG1+7Oo4ytHjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569850; 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:ARC-Authentication-Results; bh=wiODy0nVu4wzJGcUHvUbo54hOj7lPEOlLTfkCkcvPig=; b=dKatJVRuh3DLWCkQM8pTSAq21Fh/05oM9N17PcdTDw4hA9+mxFfvKxJ4vhJEJhkj6zd4Q+p0qPgc0pShF575EZamkF2VQyCvHrKCI2dDuH6bnG41WMM76MSQ71yQDYC+TpfRXbPPVtgvMhTJBiif9Q/bqfUtjQKr5ymeGcLQFYg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569850768989.6024844234655; Mon, 8 Jul 2019 00:10:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1544D83F3E; Mon, 8 Jul 2019 07:10:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2D0ABA7C; Mon, 8 Jul 2019 07:10:48 +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 A6C6C206D2; Mon, 8 Jul 2019 07:10:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x687AloE006985 for ; Mon, 8 Jul 2019 03:10:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 58CBD137F8; Mon, 8 Jul 2019 07:10:47 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03F482B1A5; Mon, 8 Jul 2019 07:10:40 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:39 +0400 Message-Id: <20190708070747.1962-16-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 15/23] qemu: add slirp helper unit 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 08 Jul 2019 07:10:49 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau The unit provides the functions associated with a slirp-helper: - probing / checking capabilities - opening the socketpair - starting / stoping the helper - registering for dbus-vmstate migration Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/Makefile.inc.am | 2 + src/qemu/qemu_domain.h | 4 + src/qemu/qemu_slirp.c | 412 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_slirp.h | 78 ++++++++ 4 files changed, 496 insertions(+) create mode 100644 src/qemu/qemu_slirp.c create mode 100644 src/qemu/qemu_slirp.h diff --git a/src/qemu/Makefile.inc.am b/src/qemu/Makefile.inc.am index 248f3970c9..e09206cb53 100644 --- a/src/qemu/Makefile.inc.am +++ b/src/qemu/Makefile.inc.am @@ -56,6 +56,8 @@ QEMU_DRIVER_SOURCES =3D \ qemu/qemu_security.h \ qemu/qemu_qapi.c \ qemu/qemu_qapi.h \ + qemu/qemu_slirp.c \ + qemu/qemu_slirp.h \ qemu/qemu_tpm.c \ qemu/qemu_tpm.h \ qemu/qemu_dbus.c \ diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 7ab44d3c43..a4463f96a3 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -511,6 +511,10 @@ struct _qemuDomainGraphicsPrivate { }; =20 =20 +typedef struct _qemuSlirp qemuSlirp; +typedef struct _qemuSlirp *qemuSlirpPtr; + + #define QEMU_DOMAIN_NETWORK_PRIVATE(dev) \ ((qemuDomainNetworkPrivatePtr) (dev)->privateData) =20 diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c new file mode 100644 index 0000000000..6600f508db --- /dev/null +++ b/src/qemu/qemu_slirp.c @@ -0,0 +1,412 @@ +/* + * qemu_slirp.c: QEMU Slirp support + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "qemu_dbus.h" +#include "qemu_extdevice.h" +#include "qemu_security.h" +#include "qemu_slirp.h" +#include "viralloc.h" +#include "virenum.h" +#include "virerror.h" +#include "virjson.h" +#include "virlog.h" +#include "virpidfile.h" +#include "virstring.h" +#include "virtime.h" + +#define VIR_FROM_THIS VIR_FROM_NONE + +VIR_LOG_INIT("qemu.slirp"); + +VIR_ENUM_IMPL(qemuSlirpFeature, + QEMU_SLIRP_FEATURE_LAST, + "", + "ipv4", + "ipv6", + "tftp", + "dbus-address", + "migrate", + "restrict", + "exit-with-parent", +); + + +void +qemuSlirpFree(qemuSlirpPtr slirp) +{ + VIR_FORCE_CLOSE(slirp->fd[0]); + VIR_FORCE_CLOSE(slirp->fd[1]); + virBitmapFree(slirp->features); + VIR_FREE(slirp); +} + + +void +qemuSlirpSetFeature(qemuSlirpPtr slirp, + qemuSlirpFeature feature) +{ + ignore_value(virBitmapSetBit(slirp->features, feature)); +} + + +bool +qemuSlirpHasFeature(const qemuSlirpPtr slirp, + qemuSlirpFeature feature) +{ + return virBitmapIsBitSet(slirp->features, feature); +} + + +qemuSlirpPtr +qemuSlirpNew(void) +{ + qemuSlirpPtr slirp =3D NULL; + + if (VIR_ALLOC(slirp) < 0) + return NULL; + + slirp->pid =3D (pid_t)-1; + slirp->fd[0] =3D slirp->fd[1] =3D -1; + slirp->features =3D virBitmapNew(QEMU_SLIRP_FEATURE_LAST); + + return slirp; +} + + +qemuSlirpPtr +qemuSlirpNewForHelper(const char *helper) +{ + VIR_AUTOPTR(qemuSlirp) slirp =3D NULL; + VIR_AUTOPTR(virCommand) cmd =3D NULL; + VIR_AUTOFREE(char *) output =3D NULL; + VIR_AUTOPTR(virJSONValue) doc =3D NULL; + virJSONValuePtr featuresJSON; + size_t i, nfeatures; + + if (!helper) + return NULL; + + slirp =3D qemuSlirpNew(); + if (!slirp) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to allocate slirp for '%s'"), helper); + return NULL; + } + + cmd =3D virCommandNewArgList(helper, "--print-capabilities", NULL); + virCommandSetOutputBuffer(cmd, &output); + if (virCommandRun(cmd, NULL) < 0) + return NULL; + + if (!(doc =3D virJSONValueFromString(output)) || + !(featuresJSON =3D virJSONValueObjectGetArray(doc, "features"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to parse json capabilities '%s'"), + helper); + return NULL; + } + + nfeatures =3D virJSONValueArraySize(featuresJSON); + for (i =3D 0; i < nfeatures; i++) { + virJSONValuePtr item =3D virJSONValueArrayGet(featuresJSON, i); + const char *tmpStr =3D virJSONValueGetString(item); + int tmp; + + if ((tmp =3D qemuSlirpFeatureTypeFromString(tmpStr)) <=3D 0) { + VIR_WARN("unknown slirp feature %s", tmpStr); + continue; + } + + qemuSlirpSetFeature(slirp, tmp); + } + + VIR_RETURN_PTR(slirp); +} + + +static char * +qemuSlirpCreatePidFilename(const char *stateDir, + const char *shortName, + const char *alias) +{ + VIR_AUTOFREE(char *) name =3D NULL; + + if (virAsprintf(&name, "%s-%s-slirp", shortName, alias) < 0) + return NULL; + + return virPidFileBuildPath(stateDir, name); +} + + +static int +qemuSlirpGetPid(const char *binPath, + const char *stateDir, + const char *shortName, + const char *alias, + pid_t *pid) +{ + VIR_AUTOFREE(char *) pidfile =3D qemuSlirpCreatePidFilename(stateDir, = shortName, alias); + if (!pidfile) + return -ENOMEM; + + return virPidFileReadPathIfAlive(pidfile, pid, binPath); +} + + +int +qemuSlirpOpen(qemuSlirpPtr slirp, + virQEMUDriverPtr driver, + virDomainDefPtr def) +{ + int rc, pair[2] =3D { -1, -1 }; + + if (qemuSecuritySetSocketLabel(driver->securityManager, def) < 0) + goto error; + + rc =3D socketpair(AF_UNIX, SOCK_DGRAM, 0, pair); + + if (qemuSecurityClearSocketLabel(driver->securityManager, def) < 0) + goto error; + + if (rc < 0) { + virReportSystemError(errno, "%s", _("failed to create socketpair")= ); + goto error; + } + + slirp->fd[0] =3D pair[0]; + slirp->fd[1] =3D pair[1]; + + return 0; + +error: + VIR_FORCE_CLOSE(pair[0]); + VIR_FORCE_CLOSE(pair[1]); + return -1; +} + + +int +qemuSlirpGetFD(qemuSlirpPtr slirp) +{ + int fd =3D slirp->fd[0]; + slirp->fd[0] =3D -1; + return fd; +} + + +static char * +qemuSlirpGetDBusVMStateId(virDomainNetDefPtr net) +{ + char macstr[VIR_MAC_STRING_BUFLEN] =3D ""; + char *id =3D NULL; + + /* can't use alias, because it's not stable across restarts */ + if (virAsprintf(&id, "slirp-%s", virMacAddrFormat(&net->mac, macstr)) = < 0) + return NULL; + + return id; +} + + +void +qemuSlirpStop(qemuSlirpPtr slirp, + virDomainObjPtr vm, + virQEMUDriverPtr driver, + virDomainNetDefPtr net) +{ + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + VIR_AUTOFREE(char *) pidfile =3D NULL; + VIR_AUTOFREE(char *) shortName =3D virDomainDefGetShortName(vm->def); + VIR_AUTOFREE(char *) id =3D qemuSlirpGetDBusVMStateId(net); + virErrorPtr orig_err; + int rc; + pid_t pid; + + if (!(pidfile =3D qemuSlirpCreatePidFilename( + cfg->stateDir, shortName, net->info.alias))) { + VIR_WARN("Unable to construct slirp pidfile path"); + return; + } + + qemuDBusVMStateRemove(vm, id); + + rc =3D qemuSlirpGetPid(cfg->slirpHelperName, + cfg->stateDir, shortName, net->info.alias, &pid); + if (rc =3D=3D 0 && pid !=3D (pid_t)-1) { + char ebuf[1024]; + + VIR_DEBUG("Killing slirp process %lld", (long long)pid); + if (virProcessKill(pid, SIGKILL) < 0 && errno !=3D ESRCH) + VIR_ERROR(_("Failed to kill process %lld: %s"), + (long long)pid, + virStrerror(errno, ebuf, sizeof(ebuf))); + } + + virErrorPreserveLast(&orig_err); + if (virPidFileForceCleanupPath(pidfile) < 0) { + VIR_WARN("Unable to kill slirp process"); + } else { + if (unlink(pidfile) < 0 && + errno !=3D ENOENT) { + virReportSystemError(errno, + _("Unable to remove stale pidfile %s"), + pidfile); + } + } + virErrorRestore(&orig_err); + slirp->pid =3D 0; +} + + +int +qemuSlirpStart(qemuSlirpPtr slirp, + virDomainObjPtr vm, + virQEMUDriverPtr driver, + virDomainNetDefPtr net, + qemuProcessIncomingDefPtr incoming) +{ + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + VIR_AUTOPTR(virCommand) cmd =3D NULL; + VIR_AUTOFREE(char *) cmdstr =3D NULL; + VIR_AUTOFREE(char *) addr =3D NULL; + VIR_AUTOFREE(char *) pidfile =3D NULL; + VIR_AUTOFREE(char *) shortName =3D virDomainDefGetShortName(vm->def); + size_t i; + virTimeBackOffVar timebackoff; + const unsigned long long timeout =3D 500 * 1000; /* ms */ + pid_t pid; + int cmdret =3D 0, exitstatus =3D 0; + + if (incoming && + !qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_MIGRATE)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("The slirp-helper doesn't support migration")); + } + + if (!(pidfile =3D qemuSlirpCreatePidFilename( + cfg->stateDir, shortName, net->info.alias))) + return -1; + + if (!(cmd =3D virCommandNew(cfg->slirpHelperName))) + return -1; + + virCommandClearCaps(cmd); + virCommandSetPidFile(cmd, pidfile); + virCommandDaemonize(cmd); + + virCommandAddArgFormat(cmd, "--fd=3D%d", slirp->fd[1]); + virCommandPassFD(cmd, slirp->fd[1], + VIR_COMMAND_PASS_FD_CLOSE_PARENT); + slirp->fd[1] =3D -1; + + for (i =3D 0; i < net->guestIP.nips; i++) { + const virNetDevIPAddr *ip =3D net->guestIP.ips[i]; + const char *opt =3D ""; + + if (!(addr =3D virSocketAddrFormat(&ip->address))) + return -1; + + if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET)) + opt =3D "--net"; + if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET6)) + opt =3D "--prefix-ipv6"; + + virCommandAddArgFormat(cmd, "%s=3D%s", opt, addr); + VIR_FREE(addr); + + if (ip->prefix) { + if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET)) { + virSocketAddr netmask; + VIR_AUTOFREE(char *) netmaskStr =3D NULL; + + if (virSocketAddrPrefixToNetmask(ip->prefix, &netmask, AF_= INET) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to translate prefix %d to net= mask"), + ip->prefix); + return -1; + } + if (!(netmaskStr =3D virSocketAddrFormat(&netmask))) + return -1; + virCommandAddArgFormat(cmd, "--mask=3D%s", netmaskStr); + } + if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET6)) + virCommandAddArgFormat(cmd, "--prefix-length-ipv6=3D%u", i= p->prefix); + } + } + + if (qemuSlirpHasFeature(slirp, + QEMU_SLIRP_FEATURE_DBUS_ADDRESS)) { + VIR_AUTOFREE(char *) id =3D qemuSlirpGetDBusVMStateId(net); + VIR_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, + _("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"); + } + + if (qemuExtDeviceLogCommand(driver, vm, cmd, "slirp") < 0) + return -1; + + if (qemuSecurityCommandRun(driver, vm, cmd, + &exitstatus, &cmdret) < 0) + return -1; + + if (cmdret < 0 || exitstatus !=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not start 'slirp'. exitstatus: %d"), exits= tatus); + return -1; + } + + /* check that the helper has written its pid into the file */ + if (virTimeBackOffStart(&timebackoff, 1, timeout) < 0) + return -1; + while (virTimeBackOffWait(&timebackoff)) { + int rc =3D qemuSlirpGetPid(cfg->slirpHelperName, + cfg->stateDir, shortName, net->info.alias= , &pid); + if (rc < 0) + continue; + if (rc =3D=3D 0 && pid =3D=3D (pid_t)-1) + return -1; + break; + } + + slirp->pid =3D pid; + return 0; +} diff --git a/src/qemu/qemu_slirp.h b/src/qemu/qemu_slirp.h new file mode 100644 index 0000000000..78a01b9dd0 --- /dev/null +++ b/src/qemu/qemu_slirp.h @@ -0,0 +1,78 @@ +/* + * qemu_slirp.h: QEMU Slirp support + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include "qemu_conf.h" +#include "qemu_domain.h" +#include "qemu_process.h" +#include "vircommand.h" + +typedef enum { + QEMU_SLIRP_FEATURE_NONE =3D 0, + QEMU_SLIRP_FEATURE_IPV4, + QEMU_SLIRP_FEATURE_IPV6, + QEMU_SLIRP_FEATURE_TFTP, + QEMU_SLIRP_FEATURE_DBUS_ADDRESS, + QEMU_SLIRP_FEATURE_MIGRATE, + QEMU_SLIRP_FEATURE_RESTRICT, + QEMU_SLIRP_FEATURE_EXIT_WITH_PARENT, + + QEMU_SLIRP_FEATURE_LAST, +} qemuSlirpFeature; + +VIR_ENUM_DECL(qemuSlirpFeature); + + +struct _qemuSlirp { + int fd[2]; + virBitmapPtr features; + pid_t pid; +}; + + +qemuSlirpPtr qemuSlirpNew(void); + +qemuSlirpPtr qemuSlirpNewForHelper(const char *helper); + +void qemuSlirpFree(qemuSlirpPtr slirp); + +void qemuSlirpSetFeature(qemuSlirpPtr slirp, + qemuSlirpFeature feature); + +bool qemuSlirpHasFeature(const qemuSlirpPtr slirp, + qemuSlirpFeature feature); + +int qemuSlirpOpen(qemuSlirpPtr slirp, + virQEMUDriverPtr driver, + virDomainDefPtr def); + +int qemuSlirpStart(qemuSlirpPtr slirp, + virDomainObjPtr vm, + virQEMUDriverPtr driver, + virDomainNetDefPtr net, + qemuProcessIncomingDefPtr incoming); + +void qemuSlirpStop(qemuSlirpPtr slirp, + virDomainObjPtr vm, + virQEMUDriverPtr driver, + virDomainNetDefPtr net); + +int qemuSlirpGetFD(qemuSlirpPtr slirp); + +VIR_DEFINE_AUTOPTR_FUNC(qemuSlirp, qemuSlirpFree); --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569865; cv=none; d=zoho.com; s=zohoarc; b=BhdfaNUd3pQnGxlHNDSyJs1yO9aWdJ7S09SBzI6+XqG9S+tBQKlL93Zpl7oqzpbyTW71S2LRXbQBc+hjhSuImBhxy1KP9fAwx3e/qgH5I2pfE481dOVN7thFVAdkjUyDyvMKVujM883wlclJX3w02BdpAWkrFLWHamNkh7b/5Ds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569865; 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:ARC-Authentication-Results; bh=yus5VIXGfE22fs2hhjMqT/uH4ZP//Jv5G6fkwU5MmPg=; b=SD/8WZWWsDovmC2KCvUuiJVHyYWuVuBn1fmipXUaWXsI/MopbmpPpusEpFaIemVGQ1TLgX4kGl2sFVufYj4RwyDoLJWX+4He2tiV3nBh93y+BqoRoJsAdo+4dlswaGHFtN1Va99HCn5klwCMSdfCnJznnNPxbIDmotbx9WH5Ly4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569865374937.5591268240655; Mon, 8 Jul 2019 00:11:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 25044C071899; Mon, 8 Jul 2019 07:11:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E26805C234; Mon, 8 Jul 2019 07:11:01 +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 96A2A206D4; Mon, 8 Jul 2019 07:11: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 x687AxWl007016 for ; Mon, 8 Jul 2019 03:10:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id C9C5480F0; Mon, 8 Jul 2019 07:10:59 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id E53F637DD; Mon, 8 Jul 2019 07:10:53 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:40 +0400 Message-Id: <20190708070747.1962-17-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-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: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 16/23] qemu-domain: save and restore slirp state 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 08 Jul 2019 07:11:03 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Save & restore the slirp helper PID associated with a network interface & the probed features. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_domain.c | 137 +++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 2 +- 2 files changed, 138 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 825c23aa26..bc34cdb3bf 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -31,6 +31,7 @@ #include "qemu_migration.h" #include "qemu_migration_params.h" #include "qemu_security.h" +#include "qemu_slirp.h" #include "qemu_extdevice.h" #include "viralloc.h" #include "virlog.h" @@ -1307,6 +1308,11 @@ qemuDomainNetworkPrivateNew(void) static void qemuDomainNetworkPrivateDispose(void *obj ATTRIBUTE_UNUSED) { + qemuDomainNetworkPrivatePtr priv =3D obj; + + if (priv->slirp) { + qemuSlirpFree(priv->slirp); + } } =20 =20 @@ -2500,6 +2506,63 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf, } =20 =20 +static bool +qemuDomainHasSlirp(virDomainObjPtr vm) +{ + size_t i; + + for (i =3D 0; i < vm->def->nnets; i++) { + virDomainNetDefPtr net =3D vm->def->nets[i]; + + if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp) + return true; + } + + return false; +} + + +static int +qemuDomainObjPrivateXMLFormatSlirp(virBufferPtr buf, + virDomainObjPtr vm) +{ + size_t i; + + if (!qemuDomainHasSlirp(vm)) + return 0; + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + + for (i =3D 0; i < vm->def->nnets; i++) { + virDomainNetDefPtr net =3D vm->def->nets[i]; + qemuSlirpPtr slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; + size_t j; + + if (!slirp) + continue; + + virBufferAsprintf(buf, "\n", + net->info.alias, slirp->pid); + + virBufferAdjustIndent(buf, 2); + for (j =3D 0; j < QEMU_SLIRP_FEATURE_LAST; j++) { + if (qemuSlirpHasFeature(slirp, j)) { + virBufferAsprintf(buf, "\n", + qemuSlirpFeatureTypeToString(j)); + } + } + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + + + return 0; +} + static int qemuDomainObjPrivateXMLFormat(virBufferPtr buf, virDomainObjPtr vm) @@ -2608,6 +2671,9 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, if (qemuDomainObjPrivateXMLFormatBlockjobs(buf, vm) < 0) return -1; =20 + if (qemuDomainObjPrivateXMLFormatSlirp(buf, vm) < 0) + return -1; + return 0; } =20 @@ -2915,6 +2981,46 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, } =20 =20 +static int +qemuDomainObjPrivateXMLParseSlirpFeatures(xmlXPathContextPtr ctxt, + size_t h, + qemuSlirpPtr slirp) +{ + VIR_AUTOFREE(char *) path =3D NULL; + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; + size_t i; + int n; + + if (virAsprintf(&path, "./slirp/helper[%ld]/feature", h + 1) < 0) + return -1; + + if ((n =3D virXPathNodeSet(path, ctxt, &nodes)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("failed to parse slirp-helper features")); + return -1; + } + + for (i =3D 0; i < n; i++) { + VIR_AUTOFREE(char *) str =3D virXMLPropString(nodes[i], "name"); + int feature; + + if (!str) + continue; + + feature =3D qemuSlirpFeatureTypeFromString(str); + if (feature < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown slirp feature %s"), str); + return -1; + } + + qemuSlirpSetFeature(slirp, feature); + } + + return 0; +} + + static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, virDomainObjPtr vm, @@ -3057,6 +3163,37 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, } VIR_FREE(nodes); =20 + if ((n =3D virXPathNodeSet("./slirp/helper", ctxt, &nodes)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to parse slirp helper list")); + goto error; + } + if (n > 0) { + for (i =3D 0; i < n; i++) { + VIR_AUTOFREE(char *) alias =3D virXMLPropString(nodes[i], "ali= as"); + VIR_AUTOFREE(char *) pid =3D virXMLPropString(nodes[i], "pid"); + VIR_AUTOPTR(qemuSlirp) slirp =3D qemuSlirpNew(); + virDomainDeviceDef dev; + + if (!alias || !pid || !slirp || + virStrToLong_i(pid, NULL, 10, &slirp->pid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to parse slirp helper list")); + goto error; + } + + if (virDomainDefFindDevice(vm->def, alias, &dev, true) < 0 || + dev.type !=3D VIR_DOMAIN_DEVICE_NET) + goto error; + + if (qemuDomainObjPrivateXMLParseSlirpFeatures(ctxt, i, slirp) = < 0) + goto error; + + VIR_STEAL_PTR(QEMU_DOMAIN_NETWORK_PRIVATE(dev.data.net)->slirp= , slirp); + } + } + VIR_FREE(nodes); + if (qemuDomainObjPrivateXMLParseAutomaticPlacement(ctxt, priv, driver)= < 0) goto error; =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index a4463f96a3..d35c800064 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -523,7 +523,7 @@ typedef qemuDomainNetworkPrivate *qemuDomainNetworkPriv= atePtr; struct _qemuDomainNetworkPrivate { virObject parent; =20 - bool tmp_to_be_larger_than_parent; + qemuSlirpPtr slirp; }; =20 =20 --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569873; cv=none; d=zoho.com; s=zohoarc; b=HV3zCoyozw2hmMy1pwOZ0Rm+pqi4QFEi5Q91MGfwyIPO1Nk87/cfcj5N2BhsfZslG1/Dl31PTTeApagkj7uZbVZCIH37kldSdWWNUtjnepk8LSQaJjPqGLDxpoCx6xSvy1aYL9rx09waEVKzDhdxeCWEyJGNPeKRhXNDLJb4nt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569873; 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:ARC-Authentication-Results; bh=B7TN7cXD3FwWDCV8HUmFB98Pxmiy8x8kVjx0HIJJzPo=; b=g7feqfDhIO0VLwVGaaWSqvg8btQsmW/eN9p4a8ne9mJVB/fsbUbZiHrJYVmx92VVASelGm5gvjVz2uNCb9ROyBSBvX5jNIc1ZdwAuJy1YekZw9IDPJKLyykd2FC/edM7dAMiAGS3JMWzaNxTYhNkb419pKbRuTWAWfvsi//qG9o= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569873403427.274953820865; Mon, 8 Jul 2019 00:11:13 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id DD24F3086217; Mon, 8 Jul 2019 07:11:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA85DD1FC; Mon, 8 Jul 2019 07:11:11 +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 75FE1206D5; Mon, 8 Jul 2019 07:11:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x687BAEr007079 for ; Mon, 8 Jul 2019 03:11:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E0E92B9F7; Mon, 8 Jul 2019 07:11:10 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F51D53E0A; Mon, 8 Jul 2019 07:11:04 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:41 +0400 Message-Id: <20190708070747.1962-18-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 17/23] qemu: add a flag to the cookie to prevent slirp-helper setup 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 08 Jul 2019 07:11:12 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau For VM started and migrated/saved without slirp-helpers, let's prevent the automatic setup (as it would fail to migrate otherwise). Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_domain.c | 12 ++++++++++-- src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 11 +++++++++-- src/qemu/qemu_process.c | 6 ++++-- src/qemu/qemu_process.h | 1 + 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bc34cdb3bf..bb719fc3c4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -13962,7 +13962,7 @@ qemuDomainSaveCookieDispose(void *obj) =20 =20 qemuDomainSaveCookiePtr -qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED) +qemuDomainSaveCookieNew(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; qemuDomainSaveCookiePtr cookie =3D NULL; @@ -13976,7 +13976,10 @@ qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBU= TE_UNUSED) if (priv->origCPU && !(cookie->cpu =3D virCPUDefCopy(vm->def->cpu))) goto error; =20 - VIR_DEBUG("Save cookie %p, cpu=3D%p", cookie, cookie->cpu); + cookie->hasSlirpHelper =3D qemuDomainHasSlirp(vm); + + VIR_DEBUG("Save cookie %p, cpu=3D%p, hasSlirpHelper=3D%d", + cookie, cookie->cpu, cookie->hasSlirpHelper); =20 return cookie; =20 @@ -14002,6 +14005,8 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt A= TTRIBUTE_UNUSED, &cookie->cpu) < 0) goto error; =20 + cookie->hasSlirpHelper =3D virXPathBoolean("boolean(./hasSlirpHelper)"= , ctxt) > 0; + *obj =3D (virObjectPtr) cookie; return 0; =20 @@ -14021,6 +14026,9 @@ qemuDomainSaveCookieFormat(virBufferPtr buf, virCPUDefFormatBufFull(buf, cookie->cpu, NULL) < 0) return -1; =20 + if (cookie->hasSlirpHelper) + virBufferAddLit(buf, "\n"); + return 0; } =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index d35c800064..9a56a90a9a 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -560,6 +560,7 @@ struct _qemuDomainSaveCookie { virObject parent; =20 virCPUDefPtr cpu; + bool hasSlirpHelper; }; =20 =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9c05ab4ad1..dda9389776 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6788,6 +6788,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); virQEMUSaveHeaderPtr header =3D &data->header; qemuDomainSaveCookiePtr cookie =3D NULL; + unsigned int flags; =20 if (virSaveCookieParseString(data->cookie, (virObjectPtr *)&cookie, virDomainXMLOptionGetSaveCookie(driver->x= mlopt)) < 0) @@ -6819,11 +6820,14 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, qemuDomainFixupCPUs(vm, &cookie->cpu) < 0) goto cleanup; =20 + flags =3D VIR_QEMU_PROCESS_START_PAUSED | VIR_QEMU_PROCESS_START_GEN_V= MID; + if (!cookie->hasSlirpHelper) + flags |=3D VIR_QEMU_PROCESS_START_NO_SLIRP; + if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL, asyncJob, "stdio", *fd, path, NULL, VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, - VIR_QEMU_PROCESS_START_PAUSED | - VIR_QEMU_PROCESS_START_GEN_VMID) =3D=3D 0) + flags) =3D=3D 0) restored =3D true; =20 if (intermediatefd !=3D -1) { @@ -16298,6 +16302,9 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, =20 start_flags |=3D VIR_QEMU_PROCESS_START_PAUSED; =20 + if (!cookie->hasSlirpHelper) + start_flags |=3D VIR_QEMU_PROCESS_START_NO_SLIRP; + /* Transitions 2, 3, 5, 6, 8, 9 */ /* When using the loadvm monitor command, qemu does not know * whether to pause or run the reverted domain, and just stays diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5e8184b0e2..93e06104f4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6680,7 +6680,8 @@ qemuProcessLaunch(virConnectPtr conn, VIR_QEMU_PROCESS_START_PAUSED | VIR_QEMU_PROCESS_START_AUTODESTROY | VIR_QEMU_PROCESS_START_NEW | - VIR_QEMU_PROCESS_START_GEN_VMID, -1); + VIR_QEMU_PROCESS_START_GEN_VMID | + VIR_QEMU_PROCESS_START_NO_SLIRP, -1); =20 cfg =3D virQEMUDriverGetConfig(driver); =20 @@ -7092,7 +7093,8 @@ qemuProcessStart(virConnectPtr conn, virCheckFlagsGoto(VIR_QEMU_PROCESS_START_COLD | VIR_QEMU_PROCESS_START_PAUSED | VIR_QEMU_PROCESS_START_AUTODESTROY | - VIR_QEMU_PROCESS_START_GEN_VMID, cleanup); + VIR_QEMU_PROCESS_START_GEN_VMID | + VIR_QEMU_PROCESS_START_NO_SLIRP, cleanup); =20 if (!migrateFrom && !snapshot) flags |=3D VIR_QEMU_PROCESS_START_NEW; diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 1d62319092..09ef124838 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -81,6 +81,7 @@ typedef enum { VIR_QEMU_PROCESS_START_GEN_VMID =3D 1 << 5, /* Generate a new VMID= */ VIR_QEMU_PROCESS_START_STANDALONE =3D 1 << 6, /* Require CLI args to= be usable standalone, ie no FD passing and = the like */ + VIR_QEMU_PROCESS_START_NO_SLIRP =3D 1 << 7, /* do not setup slirp-= helpers */ } qemuProcessStartFlags; =20 int qemuProcessStart(virConnectPtr conn, --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569884; cv=none; d=zoho.com; s=zohoarc; b=EoiPdT4rTgPWsYhs6IX2BvE2uV4s7dVSfz6vvNBYhBzxFswrPxD4aowWCwIo3UwYV1wqZ2o5LVExOz8hncJDGJxmlljN4m7IwL8Ffp+01cblpMUJQ2AXds3ieU/Vz/LH8IeDK6e1oWPFacvOiYvymSltf2KEAJl61mKFpSMvrLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569884; 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:ARC-Authentication-Results; bh=zvzHvgiloHdI58JGzaS1iJ9A5Wa4lt4Q8xIs8cIEY/4=; b=ZDYO3yAzvGSQ5bbJ/CRgbnv2WCEcyxmYAlumYStxcIl2qXiuynUf+0CigFa7/RMrhSVdmzFEUHp4QbGpL/ng4/EcIbCc9WMQ1fj3L2CfIcDwgbF50bLaLyPhow2MNWeFQ2OhOEg3jyPJYbOG5cDXbRIavkqajhAyHJQ2H+3mFLw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569884747663.1452605036357; Mon, 8 Jul 2019 00:11:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3AFFC30BDE49; Mon, 8 Jul 2019 07:11:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 166BC37DD; Mon, 8 Jul 2019 07:11:23 +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 CD90E206D6; Mon, 8 Jul 2019 07:11:22 +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 x687BL8n007096 for ; Mon, 8 Jul 2019 03:11:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7A56739C5; Mon, 8 Jul 2019 07:11:21 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id B247237DD; Mon, 8 Jul 2019 07:11:15 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:42 +0400 Message-Id: <20190708070747.1962-19-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-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: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 18/23] qemu-migration: prevent migration if slirp cannot be migrated 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 08 Jul 2019 07:11:23 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_migration.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a11c6f1a9f..35fadfec44 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -39,6 +39,7 @@ #include "qemu_hotplug.h" #include "qemu_blockjob.h" #include "qemu_security.h" +#include "qemu_slirp.h" #include "qemu_block.h" =20 #include "domain_audit.h" @@ -1146,7 +1147,17 @@ qemuMigrationSrcIsAllowed(virQEMUDriverPtr driver, _("cannot migrate domain with I/O error")); return false; } + } + + for (i =3D 0; i < vm->def->nnets; i++) { + virDomainNetDefPtr net =3D vm->def->nets[i]; + qemuSlirpPtr slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; =20 + if (slirp && !qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_MIGRAT= E)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("a slirp-helper cannot be migrated")); + return false; + } } =20 /* following checks don't make sense for offline migration */ --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569899; cv=none; d=zoho.com; s=zohoarc; b=P8LGXCTD84W0s5hI3Twp13KKa9n5YPT+axXjXK8qgfoYd8t0b4AOhP/L0Ixpgt93l+PCxIZ16xwvOI8rPufQ2Vawjj7q8Y+GTqD1xu9dLTT8pw2j1FCfCK+dMXO14cFBR8xWI22aATcDUSXuDyZvWEri7SUQKcRJJnw2y///0zY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569899; 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:ARC-Authentication-Results; bh=5LCSWzXnWNdoO2u9DX1ensv9wTfq4dfF1IDapa+fV8s=; b=VInVFmukW7FANlmIBhHpaqYKd2ASkEem+9TwqFSfdPWfFo2f6xG+xxL2cnefMx7bcCSV2F/usofvFzPnKb2OkYI9nHW4CaemCatV7u4OktAXEijK/4Igjxt5GGI3zniBGysq58WC6ai4lVbY9Kqnq09FiEzno1P5adH1NkkZBFw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569899941375.1477326987093; Mon, 8 Jul 2019 00:11:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A92B89AD0; Mon, 8 Jul 2019 07:11:38 +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 2437219C79; Mon, 8 Jul 2019 07:11:38 +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 DCC9E1833002; Mon, 8 Jul 2019 07:11:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x687Bajn007160 for ; Mon, 8 Jul 2019 03:11:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7524C17BBE; Mon, 8 Jul 2019 07:11:36 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 654972B1B9; Mon, 8 Jul 2019 07:11:26 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:43 +0400 Message-Id: <20190708070747.1962-20-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 19/23] qemu-extdevice: prepare, start and stop slirp-helper 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 08 Jul 2019 07:11:38 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau If a slirp-helper is associated with a network interface, prepare/start/stop the process via qemu-extdevice. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_extdevice.c | 46 ++++++++++++++++++++++++++++++++++----- src/qemu/qemu_extdevice.h | 8 ++++--- src/qemu/qemu_process.c | 4 ++-- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 79d5d64951..2a6cb12215 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -23,6 +23,7 @@ #include "qemu_extdevice.h" #include "qemu_domain.h" #include "qemu_tpm.h" +#include "qemu_slirp.h" =20 #include "viralloc.h" #include "virlog.h" @@ -87,14 +88,24 @@ qemuExtDevicesInitPaths(virQEMUDriverPtr driver, */ int qemuExtDevicesPrepareHost(virQEMUDriverPtr driver, - virDomainDefPtr def) + virDomainObjPtr vm) { - int ret =3D 0; + virDomainDefPtr def =3D vm->def; + size_t i; =20 - if (def->tpm) - ret =3D qemuExtTPMPrepareHost(driver, def); + if (def->tpm && + qemuExtTPMPrepareHost(driver, def) < 0) + return -1; =20 - return ret; + for (i =3D 0; i < def->nnets; i++) { + virDomainNetDefPtr net =3D def->nets[i]; + qemuSlirpPtr slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; + + if (slirp && qemuSlirpOpen(slirp, driver, def) < 0) + return -1; + } + + return 0; } =20 =20 @@ -112,9 +123,12 @@ qemuExtDevicesCleanupHost(virQEMUDriverPtr driver, =20 int qemuExtDevicesStart(virQEMUDriverPtr driver, - virDomainObjPtr vm) + virDomainObjPtr vm, + qemuProcessIncomingDefPtr incoming) { + virDomainDefPtr def =3D vm->def; int ret =3D 0; + size_t i; =20 if (qemuExtDevicesInitPaths(driver, vm->def) < 0) return -1; @@ -122,6 +136,15 @@ qemuExtDevicesStart(virQEMUDriverPtr driver, if (vm->def->tpm) ret =3D qemuExtTPMStart(driver, vm); =20 + for (i =3D 0; i < def->nnets; i++) { + virDomainNetDefPtr net =3D def->nets[i]; + qemuSlirpPtr slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; + + if (slirp && + qemuSlirpStart(slirp, vm, driver, net, incoming) < 0) + return -1; + } + return ret; } =20 @@ -130,11 +153,22 @@ void qemuExtDevicesStop(virQEMUDriverPtr driver, virDomainObjPtr vm) { + virDomainDefPtr def =3D vm->def; + size_t i; + if (qemuExtDevicesInitPaths(driver, vm->def) < 0) return; =20 if (vm->def->tpm) qemuExtTPMStop(driver, vm); + + for (i =3D 0; i < def->nnets; i++) { + virDomainNetDefPtr net =3D def->nets[i]; + qemuSlirpPtr slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; + + if (slirp) + qemuSlirpStop(slirp, vm, driver, net); + } } =20 =20 diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h index c9a3109fb6..39502b57a6 100644 --- a/src/qemu/qemu_extdevice.h +++ b/src/qemu/qemu_extdevice.h @@ -22,6 +22,7 @@ =20 #include "qemu_conf.h" #include "qemu_domain.h" +#include "qemu_process.h" =20 int qemuExtDeviceLogCommand(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -31,7 +32,7 @@ int qemuExtDeviceLogCommand(virQEMUDriverPtr driver, ATTRIBUTE_RETURN_CHECK; =20 int qemuExtDevicesPrepareHost(virQEMUDriverPtr driver, - virDomainDefPtr def) + virDomainObjPtr vm) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; =20 @@ -40,8 +41,9 @@ void qemuExtDevicesCleanupHost(virQEMUDriverPtr driver, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 int qemuExtDevicesStart(virQEMUDriverPtr driver, - virDomainObjPtr vm) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) + virDomainObjPtr vm, + qemuProcessIncomingDefPtr incoming) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; =20 void qemuExtDevicesStop(virQEMUDriverPtr driver, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 93e06104f4..d067223a0e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6535,7 +6535,7 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, goto cleanup; =20 VIR_DEBUG("Preparing external devices"); - if (qemuExtDevicesPrepareHost(driver, vm->def) < 0) + if (qemuExtDevicesPrepareHost(driver, vm) < 0) goto cleanup; =20 if (qemuProcessPrepareSEVGuestInput(vm) < 0) @@ -6710,7 +6710,7 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuProcessGenID(vm, flags) < 0) goto cleanup; =20 - if (qemuExtDevicesStart(driver, vm) < 0) + if (qemuExtDevicesStart(driver, vm, incoming) < 0) goto cleanup; =20 VIR_DEBUG("Building emulator command line"); --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569911; cv=none; d=zoho.com; s=zohoarc; b=X3UTahOfZL1tpGaP12Edd+11vAvXfiWd3dufZCyu2eoWDmmF91E8EfGrQetzZnWP8zMh/n6+znN7WCH+ShrmP8B4B3Lwl0mS+nzWzjhG2qgiqfS3GIT5BcU1pIm8G51+wpy+Qe1oW+fWjaDvf8Wy9eJePqKzGTuSJUeWXuqL+Rw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569911; 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:ARC-Authentication-Results; bh=YpxWdv52KRrojFfYmrNJaYaueJ7lP4ZuRyrrjzhbSp4=; b=fFK461Nnsj5r4U+9Dl4RtaTLs4ErFxGhBtFLNeQOHEg5EKpZUJR7uRMNkmloinYWj7qBEB2129Wtk7/zLzpkmuGUpKCB/qdfvr77WPpttQfOx/mivGyay16AKRQ2TtjqkebtqN97bCKjeQ8azV18OMBvPzn5otTSASr5CL5ZRVI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569911759750.1330287632607; Mon, 8 Jul 2019 00:11:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26CAF30860AA; Mon, 8 Jul 2019 07:11:50 +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 F205C5C22B; Mon, 8 Jul 2019 07:11:49 +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 873EE1833004; Mon, 8 Jul 2019 07:11:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x687Bl9q007507 for ; Mon, 8 Jul 2019 03:11:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id A7E405DA2E; Mon, 8 Jul 2019 07:11:47 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id E17ED5D9E5; Mon, 8 Jul 2019 07:11:40 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:44 +0400 Message-Id: <20190708070747.1962-21-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 20/23] qemu-command: use -net socket, fd= with slirp-helper 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 08 Jul 2019 07:11:50 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau If a slirp-helper is associated with a network interface (after probing & preparing succesfully), pass the socket fd to QEMU and use "-net socket,fd=3D". Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_command.c | 35 +++++++++++++++++++++++++++++------ src/qemu/qemu_command.h | 3 ++- src/qemu/qemu_hotplug.c | 4 +++- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 040e8e2b12..e15d19eb25 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -28,6 +28,7 @@ #include "qemu_interface.h" #include "qemu_alias.h" #include "qemu_security.h" +#include "qemu_slirp.h" #include "qemu_block.h" #include "cpu/cpu.h" #include "dirname.h" @@ -4038,7 +4039,8 @@ qemuBuildHostNetStr(virDomainNetDefPtr net, char **tapfd, size_t tapfdSize, char **vhostfd, - size_t vhostfdSize) + size_t vhostfdSize, + const char *slirpfd) { bool is_tap =3D false; virBuffer buf =3D VIR_BUFFER_INITIALIZER; @@ -4109,6 +4111,12 @@ qemuBuildHostNetStr(virDomainNetDefPtr net, break; =20 case VIR_DOMAIN_NET_TYPE_USER: + if (slirpfd) { + virBufferAsprintf(&buf, "socket,fd=3D%s,", + slirpfd); + break; + } + virBufferAddLit(&buf, "user,"); for (i =3D 0; i < net->guestIP.nips; i++) { const virNetDevIPAddr *ip =3D net->guestIP.ips[i]; @@ -8654,10 +8662,10 @@ qemuInterfaceVhostuserConnect(virQEMUDriverPtr driv= er, =20 static int qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, + virDomainObjPtr vm, virLogManagerPtr logManager, virSecurityManagerPtr secManager, virCommandPtr cmd, - virDomainDefPtr def, virDomainNetDefPtr net, virQEMUCapsPtr qemuCaps, unsigned int bootindex, @@ -8666,6 +8674,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, size_t *nnicindexes, int **nicindexes) { + virDomainDefPtr def =3D vm->def; int ret =3D -1; char *nic =3D NULL; char *host =3D NULL; @@ -8676,9 +8685,11 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr drive= r, size_t vhostfdSize =3D 0; char **tapfdName =3D NULL; char **vhostfdName =3D NULL; + VIR_AUTOFREE(char *) slirpfdName =3D NULL; virDomainNetType actualType =3D virDomainNetGetActualType(net); virNetDevBandwidthPtr actualBandwidth; bool requireNicdev =3D false; + qemuSlirpPtr slirp; size_t i; =20 =20 @@ -8904,6 +8915,16 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr drive= r, goto cleanup; } =20 + slirp =3D QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp; + if (slirp && !standalone) { + int slirpfd =3D qemuSlirpGetFD(slirp); + virCommandPassFD(cmd, slirpfd, + VIR_COMMAND_PASS_FD_CLOSE_PARENT); + if (virAsprintf(&slirpfdName, "%d", slirpfd) < 0) + goto cleanup; + } + + for (i =3D 0; i < tapfdSize; i++) { if (qemuSecuritySetTapFDLabel(driver->securityManager, def, tapfd[i]) < 0) @@ -8928,7 +8949,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, =20 if (!(host =3D qemuBuildHostNetStr(net, driver, tapfdName, tapfdSize, - vhostfdName, vhostfdSize))) + vhostfdName, vhostfdSize, + slirpfdName))) goto cleanup; virCommandAddArgList(cmd, "-netdev", host, NULL); =20 @@ -8996,10 +9018,10 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driv= er, */ static int qemuBuildNetCommandLine(virQEMUDriverPtr driver, + virDomainObjPtr vm, virLogManagerPtr logManager, virSecurityManagerPtr secManager, virCommandPtr cmd, - virDomainDefPtr def, virQEMUCapsPtr qemuCaps, virNetDevVPortProfileOp vmop, bool standalone, @@ -9010,6 +9032,7 @@ qemuBuildNetCommandLine(virQEMUDriverPtr driver, size_t i; int last_good_net =3D -1; virErrorPtr originalError =3D NULL; + virDomainDefPtr def =3D vm->def; =20 if (def->nnets) { unsigned int bootNet =3D 0; @@ -9025,7 +9048,7 @@ qemuBuildNetCommandLine(virQEMUDriverPtr driver, for (i =3D 0; i < def->nnets; i++) { virDomainNetDefPtr net =3D def->nets[i]; =20 - if (qemuBuildInterfaceCommandLine(driver, logManager, secManag= er, cmd, def, net, + if (qemuBuildInterfaceCommandLine(driver, vm, logManager, secM= anager, cmd, net, qemuCaps, bootNet, vmop, standalone, nnicindexes, nicindexes) < 0) @@ -10817,7 +10840,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildFSDevCommandLine(cmd, def, qemuCaps) < 0) goto error; =20 - if (qemuBuildNetCommandLine(driver, logManager, secManager, cmd, def, + if (qemuBuildNetCommandLine(driver, vm, logManager, secManager, cmd, qemuCaps, vmop, standalone, nnicindexes, nicindexes, &bootHostdevNet) = < 0) goto error; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 8bb941e2bc..71afacbc0e 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -90,7 +90,8 @@ char *qemuBuildHostNetStr(virDomainNetDefPtr net, char **tapfd, size_t tapfdSize, char **vhostfd, - size_t vhostfdSize); + size_t vhostfdSize, + const char *slirpfd); =20 /* Current, best practice */ char *qemuBuildNicDevStr(virDomainDefPtr def, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ccff9a79d7..6e390c6ce4 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1142,6 +1142,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv =3D vm->privateData; virDomainDeviceDef dev =3D { VIR_DOMAIN_DEVICE_NET, { .net =3D net } }; virErrorPtr originalError =3D NULL; + VIR_AUTOFREE(char *) slirpfdName =3D NULL; char **tapfdName =3D NULL; int *tapfd =3D NULL; size_t tapfdSize =3D 0; @@ -1380,7 +1381,8 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, =20 if (!(netstr =3D qemuBuildHostNetStr(net, driver, tapfdName, tapfdSize, - vhostfdName, vhostfdSize))) + vhostfdName, vhostfdSize, + slirpfdName))) goto cleanup; =20 qemuDomainObjEnterMonitor(driver, vm); --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569921; cv=none; d=zoho.com; s=zohoarc; b=lHBj+7piMDXneL0VtpJHmmQN5qIY5SHf8gtDvBf+oiyTm8V+a9r5L3oiAyaNQM493NZf4jmByjZaIc7+6CF4eRJXucxlDZbL15OCUJVC9fOftS6SMx3abZ2C5hZ/WFtoeiyHJR6XC6pa9hw7TcTBWwTrZeIguNKNEbWsjKFnf50= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569921; 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:ARC-Authentication-Results; bh=JzlfLriyq11W4dU6bFrBSht9fjJWZZ2MvenK6yQQqTk=; b=ATh7pZGClNesGm55ZNq9ieOngPrgTWkvKGwwnwkLFhZAjaYqZak/7DWf5qiMFeiBM9IKLZo3pirg2aLr4hTv3M8sINTxa2cwz1vy5tW3nCcRFjui/teu0MLqd9p5AXPuCq0wZmf191HRoXbvOLcpntzA7CFNKaK28dePtZcMSF0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569921894533.7115073373277; Mon, 8 Jul 2019 00:12:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16F783154846; Mon, 8 Jul 2019 07:12:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC90617D4D; Mon, 8 Jul 2019 07:11:59 +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 9F1BE206D2; Mon, 8 Jul 2019 07:11:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x687Bwli007549 for ; Mon, 8 Jul 2019 03:11:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id B9D305458D; Mon, 8 Jul 2019 07:11:58 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E15353C30; Mon, 8 Jul 2019 07:11:52 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:45 +0400 Message-Id: <20190708070747.1962-22-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 21/23] qemu-process: prepare slirp-helper 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 08 Jul 2019 07:12:00 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau When the network interface is of "user" type, and QEMU has the "-net socket,fd=3D" datagram support, call qemuInterfacePrepareSlirp() to probe and associate a slirp-helper with the interface. The usage of automated slirp-helper can be prevented with VIR_QEMU_PROCESS_START_NO_SLIRP (in particular when resuming a VM that didn't start with slirp-helper before). Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_interface.c | 27 +++++++++++++++++++++++++++ src/qemu/qemu_interface.h | 4 ++++ src/qemu/qemu_process.c | 17 ++++++++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index c8effa68f4..e58f464d87 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -603,6 +603,33 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, } =20 =20 +qemuSlirpPtr +qemuInterfacePrepareSlirp(virQEMUDriverPtr driver, + virDomainNetDefPtr net) +{ + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + VIR_AUTOPTR(qemuSlirp) slirp =3D NULL; + size_t i; + + if (!(slirp =3D qemuSlirpNewForHelper(cfg->slirpHelperName))) + return NULL; + + for (i =3D 0; i < net->guestIP.nips; i++) { + const virNetDevIPAddr *ip =3D net->guestIP.ips[i]; + + if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET) && + !qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_IPV4)) + return NULL; + + if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET6) && + !qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_IPV6)) + return NULL; + } + + VIR_RETURN_PTR(slirp); +} + + /** * qemuInterfaceOpenVhostNet: * @def: domain definition diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h index 5a2f87e532..0464b903d7 100644 --- a/src/qemu/qemu_interface.h +++ b/src/qemu/qemu_interface.h @@ -24,6 +24,7 @@ #include "domain_conf.h" #include "qemu_conf.h" #include "qemu_domain.h" +#include "qemu_slirp.h" =20 int qemuInterfaceStartDevice(virDomainNetDefPtr net); int qemuInterfaceStartDevices(virDomainDefPtr def); @@ -54,3 +55,6 @@ int qemuInterfaceOpenVhostNet(virDomainDefPtr def, virDomainNetDefPtr net, int *vhostfd, size_t *vhostfdSize); + +qemuSlirpPtr qemuInterfacePrepareSlirp(virQEMUDriverPtr driver, + virDomainNetDefPtr net); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d067223a0e..856460f0b6 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5619,8 +5619,12 @@ qemuProcessInit(virQEMUDriverPtr driver, * qemuProcessNetworkPrepareDevices */ static int -qemuProcessNetworkPrepareDevices(virDomainDefPtr def) +qemuProcessNetworkPrepareDevices(virQEMUDriverPtr driver, + virDomainObjPtr vm, + unsigned int flags) { + virDomainDefPtr def =3D vm->def; + qemuDomainObjPrivatePtr priv =3D vm->privateData; int ret =3D -1; size_t i; virConnectPtr conn =3D NULL; @@ -5665,7 +5669,14 @@ qemuProcessNetworkPrepareDevices(virDomainDefPtr def) } if (virDomainHostdevInsert(def, hostdev) < 0) goto cleanup; - } + } else if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_USER && + !(flags & VIR_QEMU_PROCESS_START_NO_SLIRP) && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NET_SOCKET_DGR= AM)) { + qemuSlirpPtr slirp =3D qemuInterfacePrepareSlirp(driver, net); + + QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp =3D slirp; + } + } ret =3D 0; cleanup: @@ -6468,7 +6479,7 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, * will need to be setup. */ VIR_DEBUG("Preparing network devices"); - if (qemuProcessNetworkPrepareDevices(vm->def) < 0) + if (qemuProcessNetworkPrepareDevices(driver, vm, flags) < 0) goto cleanup; =20 /* Must be run before security labelling */ --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569929; cv=none; d=zoho.com; s=zohoarc; b=JltCc/spdDimZxOPltWZA40LLl+HnVMvYra8+DT7qc04fyukEsh+tEBvZsjj/OGtZqNj0VByEKJTqMqnWEyWaavjtdBq64V2Yr1FXkV/pt1mDQ9gZFi072JCU0r2XStVSPG9y9EXl2R0sCq+STi6KvBTBK0OvdeLln5TjGsAWhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569929; 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:ARC-Authentication-Results; bh=BU+QC54wHHletnckaxGs6yiEnYaCCkSJ5S81hq3EdEw=; b=XkNBG8xsasSQV00B7leRTDgOh/eG8eoq+pyBrhgr08XtljwdeT8KPgRMW2p31TtGukYFWuwF0NIV520tRdDmeDcBIo0iC/D+/HdA5jzSNiPRcRDt6VDGl7bGqXyDaE5JzM6wV907Rdc40GHETaypOnY6YyS0JP/cTr0s6us7onk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569929833873.8815631130296; Mon, 8 Jul 2019 00:12:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 238107FDF4; Mon, 8 Jul 2019 07:12:08 +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 EE39BBAB1; Mon, 8 Jul 2019 07:12:07 +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 9DB451833005; Mon, 8 Jul 2019 07:12:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x687C6ER007887 for ; Mon, 8 Jul 2019 03:12:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 33C4F57983; Mon, 8 Jul 2019 07:12:06 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF4B65798A; Mon, 8 Jul 2019 07:12:03 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:46 +0400 Message-Id: <20190708070747.1962-23-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 22/23] qemu-hotplug: handle hotplugging of slirp-helper 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 08 Jul 2019 07:12:08 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_hotplug.c | 32 +++++++++++++++++++++++++++++--- src/qemu/qemu_monitor.c | 13 ++++++++++--- src/qemu/qemu_monitor.h | 3 ++- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6e390c6ce4..cb4665ab01 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1143,6 +1143,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, virDomainDeviceDef dev =3D { VIR_DOMAIN_DEVICE_NET, { .net =3D net } }; virErrorPtr originalError =3D NULL; VIR_AUTOFREE(char *) slirpfdName =3D NULL; + int slirpfd =3D -1; char **tapfdName =3D NULL; int *tapfd =3D NULL; size_t tapfdSize =3D 0; @@ -1322,7 +1323,25 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, break; =20 case VIR_DOMAIN_NET_TYPE_USER: - /* No preparation needed. */ + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NET_SOCKET_DGRAM)) { + qemuSlirpPtr slirp =3D qemuInterfacePrepareSlirp(driver, net); + + if (!slirp) + break; + + QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp =3D slirp; + + if (qemuSlirpOpen(slirp, driver, vm->def) < 0 || + qemuSlirpStart(slirp, vm, driver, net, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Failed to start slirp")); + goto cleanup; + } + + slirpfd =3D qemuSlirpGetFD(slirp); + if (virAsprintf(&slirpfdName, "slirpfd-%s", net->info.alias) <= 0) + goto cleanup; + } break; =20 case VIR_DOMAIN_NET_TYPE_SERVER: @@ -1398,7 +1417,8 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, =20 if (qemuMonitorAddNetdev(priv->mon, netstr, tapfd, tapfdName, tapfdSize, - vhostfd, vhostfdName, vhostfdSize) < 0) { + vhostfd, vhostfdName, vhostfdSize, + slirpfd, slirpfdName) < 0) { ignore_value(qemuDomainObjExitMonitor(driver, vm)); virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; @@ -1513,6 +1533,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, VIR_FREE(charDevAlias); virObjectUnref(conn); virDomainCCWAddressSetFree(ccwaddrs); + VIR_FORCE_CLOSE(slirpfd); =20 return ret; =20 @@ -1523,6 +1544,8 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, virErrorPreserveLast(&originalError); if (virAsprintf(&netdev_name, "host%s", net->info.alias) >=3D 0) { qemuDomainObjEnterMonitor(driver, vm); + if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp) + qemuSlirpStop(QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp, vm, dri= ver, net); if (charDevPlugged && qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0) VIR_WARN("Failed to remove associated chardev %s", charDevAlia= s); @@ -2208,7 +2231,7 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, =20 if (guestfwd) { if (qemuMonitorAddNetdev(priv->mon, devstr, - NULL, NULL, 0, NULL, NULL, 0) < 0) + NULL, NULL, 0, NULL, NULL, 0, -1, NULL) <= 0) goto exit_monitor; } else { if (qemuMonitorAddDevice(priv->mon, devstr) < 0) @@ -4669,6 +4692,9 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, } } =20 + if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp) + qemuSlirpStop(QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp, vm, driver,= net); + if (qemuDomainObjExitMonitor(driver, vm) < 0) goto cleanup; =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index ea57bad9f5..66d046bfe0 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2853,15 +2853,17 @@ int qemuMonitorAddNetdev(qemuMonitorPtr mon, const char *netdevstr, int *tapfd, char **tapfdName, int tapfdSize, - int *vhostfd, char **vhostfdName, int vhostfdSize) + int *vhostfd, char **vhostfdName, int vhostfdSize, + int slirpfd, char *slirpfdName) { int ret =3D -1; size_t i =3D 0, j =3D 0; =20 VIR_DEBUG("netdevstr=3D%s tapfd=3D%p tapfdName=3D%p tapfdSize=3D%d" - "vhostfd=3D%p vhostfdName=3D%p vhostfdSize=3D%d", + "vhostfd=3D%p vhostfdName=3D%p vhostfdSize=3D%d" + "slirpfd=3D%d slirpfdName=3D%s", netdevstr, tapfd, tapfdName, tapfdSize, - vhostfd, vhostfdName, vhostfdSize); + vhostfd, vhostfdName, vhostfdSize, slirpfd, slirpfdName); =20 QEMU_CHECK_MONITOR(mon); =20 @@ -2874,6 +2876,11 @@ qemuMonitorAddNetdev(qemuMonitorPtr mon, goto cleanup; } =20 + if (slirpfd !=3D -1) { + if (qemuMonitorSendFileHandle(mon, slirpfdName, slirpfd) < 0) + goto cleanup; + } + ret =3D qemuMonitorJSONAddNetdev(mon, netdevstr); =20 cleanup: diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index fcb029f97f..af20e92506 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -832,7 +832,8 @@ int qemuMonitorRemoveFd(qemuMonitorPtr mon, int fdset, = int fd); int qemuMonitorAddNetdev(qemuMonitorPtr mon, const char *netdevstr, int *tapfd, char **tapfdName, int tapfdSize, - int *vhostfd, char **vhostfdName, int vhostfdSize= ); + int *vhostfd, char **vhostfdName, int vhostfdSize, + int slirpfd, char *slirpfdName); =20 int qemuMonitorRemoveNetdev(qemuMonitorPtr mon, const char *alias); --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 07:56:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562569943; cv=none; d=zoho.com; s=zohoarc; b=Ssgc06TU/IzNfegLf2FGkhn0TDZc4xEiQqXGm4V3ZiXALHCQH6ENxb7A4Um0QIgcB6Vg/EDGC3j0ViRkDpjNGDXByYajdRkt7RQS2goxg58F1/+ZfDC0tP09Nv2mUmrVXuWvE835EnXujIANwerlPezcCOHu82nDexjq7gICZN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569943; 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:ARC-Authentication-Results; bh=r3iLr4PY+q657BBS/X4r0T6K/uFT7VWIrZz5wEDz7ho=; b=BGjVMiAPiJNyfHKEeSGATgbCmui8HttFQrEBNv7i3PIIGjIVQU1yQ/SnVYkhcgyOUvMnXZGTbgJ3C9LGDSHtbuV9/zzLZ5QzojdFTYr5h3WT5RfFsKlB5U/X3FROE84YG4eq52B4C9fuMsMXJLezIh1V2coz9dwzNwVGLrKynlI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562569943704485.37535425040164; Mon, 8 Jul 2019 00:12:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E9AB8F917; Mon, 8 Jul 2019 07:12:22 +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 EB4FC2B1BB; Mon, 8 Jul 2019 07:12:21 +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 AFB181833006; Mon, 8 Jul 2019 07:12:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x687CKIJ007946 for ; Mon, 8 Jul 2019 03:12:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 025EB5C22F; Mon, 8 Jul 2019 07:12:20 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F83E5C226; Mon, 8 Jul 2019 07:12:10 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:47 +0400 Message-Id: <20190708070747.1962-24-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 23/23] tests: add slirp-helper qemuxml2argv test 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 08 Jul 2019 07:12:22 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- .../net-user.x86_64-4.0.0.args | 34 +++++++++++++++++++ tests/qemuxml2argvtest.c | 16 +++++++++ tests/testutilsqemu.h | 1 + 3 files changed, 51 insertions(+) create mode 100644 tests/qemuxml2argvdata/net-user.x86_64-4.0.0.args diff --git a/tests/qemuxml2argvdata/net-user.x86_64-4.0.0.args b/tests/qemu= xml2argvdata/net-user.x86_64-4.0.0.args new file mode 100644 index 0000000000..ef4b77be92 --- /dev/null +++ b/tests/qemuxml2argvdata/net-user.x86_64-4.0.0.args @@ -0,0 +1,34 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i686 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,file=3D/tmp/lib/domain--1-QEMU= Guest1/master-key.aes \ +-machine pc-i440fx-4.0,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 214 \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ +-netdev socket,fd=3D42,id=3Dhostnet0 \ +-device rtl8139,netdev=3Dhostnet0,id=3Dnet0,mac=3D00:11:22:33:44:55,bus=3D= pci.0,addr=3D0x2 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 0ac128be00..1436a36b03 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -17,6 +17,7 @@ # include "qemu/qemu_domain.h" # include "qemu/qemu_migration.h" # include "qemu/qemu_process.h" +# include "qemu/qemu_slirp.h" # include "datatypes.h" # include "conf/storage_conf.h" # include "cpu/cpu_map.h" @@ -398,6 +399,7 @@ testCheckExclusiveFlags(int flags) FLAG_FIPS | FLAG_REAL_CAPS | FLAG_SKIP_LEGACY_CPUS | + FLAG_SLIRP_HELPER | 0, -1); =20 VIR_EXCLUSIVE_FLAGS_RET(FLAG_REAL_CAPS, FLAG_SKIP_LEGACY_CPUS, -1); @@ -526,6 +528,19 @@ testCompareXMLToArgv(const void *data) } } =20 + if (flags & FLAG_SLIRP_HELPER) { + for (i =3D 0; i < vm->def->nnets; i++) { + virDomainNetDefPtr net =3D vm->def->nets[i]; + + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER && + virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_NET_SOCKET_DGRAM)= ) { + qemuSlirpPtr slirp =3D qemuSlirpNew(); + slirp->fd[0] =3D 42; + QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp =3D slirp; + } + } + } + if (!(cmd =3D qemuProcessCreatePretendCmd(&driver, vm, migrateURI, (flags & FLAG_FIPS), false, VIR_QEMU_PROCESS_START_COLD)))= { @@ -1280,6 +1295,7 @@ mymain(void) DO_TEST_FAILURE("net-vhostuser-fail", QEMU_CAPS_VHOSTUSER_MULTIQUEUE); DO_TEST("net-user", NONE); + DO_TEST_CAPS_ARCH_VER_FULL("net-user", "x86_64", "4.0.0", ARG_FLAGS, F= LAG_SLIRP_HELPER); DO_TEST("net-user-addr", NONE); DO_TEST("net-virtio", NONE); DO_TEST("net-virtio-device", diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 0632141d68..a2f7bfcc26 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -51,6 +51,7 @@ typedef enum { FLAG_FIPS =3D 1 << 2, FLAG_REAL_CAPS =3D 1 << 3, FLAG_SKIP_LEGACY_CPUS =3D 1 << 4, + FLAG_SLIRP_HELPER =3D 1 << 5, } testQemuInfoFlags; =20 struct testQemuInfo { --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list