From nobody Thu Mar 28 08:48:10 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=1565276276; cv=none; d=zoho.com; s=zohoarc; b=JnRNiZAr7kA11j61+UGdpwLQ+dI5YjAdz2CTlU5OmINv9XRiwvhbDlklO0+k8HCKekfUHtiX64dYwMtcbVRP3AdhwgIG0l9yjFEfGwpF1nC2ecqQwxDR2rpre0I+i3/ba1RcW8++VzaLj74LNnMc/2wIpH7szweVztD2QlplbOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276276; 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=0Pyj8x/roUa2NQ05PUeoR75VKC8Diu/DLJDnrXc0bCw=; b=iNzMOXm1m4rWkmI9iv1hxbcynCdRdtg4GJHhClLYwk9L5Ig1vziubmPtDzno5zF+PQR0xnc0r7yzKqGu7kSj8M6BYtWB4LHL1k981/QN05JkB1QIGah/Onxoknpx8W8ykRgzR+fSpC/vzvwPiTB21rCrJuHb3wtbNnRYXfp85fE= 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 1565276276551552.0617565481949; Thu, 8 Aug 2019 07:57:56 -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 C57F2306731E; Thu, 8 Aug 2019 14:57:54 +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 58022194B9; Thu, 8 Aug 2019 14:57:53 +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 AAE1E83542; Thu, 8 Aug 2019 14:57:50 +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 x78EtZN7022834 for ; Thu, 8 Aug 2019 10:55:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id E3A2360BF1; Thu, 8 Aug 2019 14:55:35 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0690560BEC; Thu, 8 Aug 2019 14:55:28 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:54:52 +0400 Message-Id: <20190808145514.20789-2-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 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.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.48]); Thu, 08 Aug 2019 14:57:55 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Consistent code style across editors. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- .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.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276298; cv=none; d=zoho.com; s=zohoarc; b=Y0lCyAUyn56jlraF1tLNi8UroD1kQbnOhYl2pKpSkF8o4Z5c2cMaQ4lgnFA35kSR0t+EvM8T4fxEdCNxvhGKo4JFQJhet16XZgzg1AsUcped0dEHFYHoh8sb83Cp29bBAaBtoiCHE71p0BkUJqSXUKdJjWsNf9CrB48HXtBwJWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276298; 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=vnvos8dqCUm/Y9eZghWpoOhBSdtOL8cOlRvwzY1AR+o=; b=Z4atxpX+RrioBlxLYgDvrnpkY6K/84c5YGXl8z1vtVmzfK7walciNVHO0eygb4LO/wXOnKnaGyE+zLVyzgNhN2oBwX+6OBkbjcp89d0yn+98A0v21ci1BB90NZ/UpaRzKKTlakXteeQy11UlJ6nVVU0nFtGWsX+28sZ5fk+VbAQ= 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 1565276298096480.7590276006172; Thu, 8 Aug 2019 07:58:18 -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 BAFE43023085; Thu, 8 Aug 2019 14:58:16 +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 930AA60C5E; Thu, 8 Aug 2019 14:58: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 51954180124D; Thu, 8 Aug 2019 14:58: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 x78EtgZ1022846 for ; Thu, 8 Aug 2019 10:55:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD6C460BF1; Thu, 8 Aug 2019 14:55:42 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE8CF60BE1; Thu, 8 Aug 2019 14:55:41 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:54:53 +0400 Message-Id: <20190808145514.20789-3-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 02/23] tests: fix xml2xml tpm-emulator.xml 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.45]); Thu, 08 Aug 2019 14:58:17 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau It is failing, because it ends up being parsed with version=3D'default' and expects '1.2' instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- tests/qemuxml2argvdata/tpm-emulator.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemuxml2argvdata/tpm-emulator.xml b/tests/qemuxml2argvda= ta/tpm-emulator.xml index 7f1e5756cb..defc3789ad 100644 --- a/tests/qemuxml2argvdata/tpm-emulator.xml +++ b/tests/qemuxml2argvdata/tpm-emulator.xml @@ -23,7 +23,7 @@ - + --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276322; cv=none; d=zoho.com; s=zohoarc; b=gdhIzquRVLFg1yEdpUdMVW/BOVTfRSgv6OKIRMsjjnb8F4cHetuSNOlTEeNLU1V88WxKt2bx5Kxz31S9kCNSXWLj9hlIf3/Ml5kC8q1NPJmSRicblKEiYp+lhp/9fhQ3hs9E8UOG3/azvv9Hzmn558VLtKCnyIO7U+QvyY4dhsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276322; 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=U8AOTZhtPzYOdXuvnePG63tHrY4reaGD/O1yUL+Gq/I=; b=ZVKih3JUuGlQGZPWmMrdnCNsTomJ1ME1NLgOzunKylr8m0+A/jZs/MQP0lmfd8gKUjhAg4YDmwKaHAMQnfeAFRorXaNFH8+8FkarzBONa7IiJDHIYOM3fanVSRad/UtX162yHxm8PUcf9/0t0o+Xy9YppkGKlxVo21G8oUIMOug= 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 1565276322027978.1883534685355; Thu, 8 Aug 2019 07:58:42 -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 874F03098432; Thu, 8 Aug 2019 14:58:40 +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 5D3FA60A35; Thu, 8 Aug 2019 14:58: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 1E7B4180BAA0; Thu, 8 Aug 2019 14:58:40 +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 x78Etr2d022858 for ; Thu, 8 Aug 2019 10:55:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id C4301608AB; Thu, 8 Aug 2019 14:55:53 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27E9060A9D; Thu, 8 Aug 2019 14:55:47 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:54:54 +0400 Message-Id: <20190808145514.20789-4-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 03/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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 08 Aug 2019 14:58:41 +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 Reviewed-by: Michal Privoznik --- 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.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276301; cv=none; d=zoho.com; s=zohoarc; b=l6IwJW23BOwhrmT7xTlxIDKnNmDANBosWc8B0WXsDrmBoXQByjd34eR29DEbizhFq348EmY6WQDlb4csxx7rdn/uW8vsMXy9+zVKSnftrU+paGh3kWHAsqrWy4HF9lG1kJ57ygkqGvYmA8IACWL+Z1BoSVRXANDFco95G9DHodQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276301; 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=vDdoym/0me1ASgMp5qK2Wo2Ckk/DW/j561tlrJTJESY=; b=V1OHDeMc3Q6uQlmdt96vXPWkMWZs84PZ0et+qohbZFAH+mKnyBTmj2BOVmChBc39VCDA+qR4Xt4h2Z1yXIbjUgI9ldRf1Nniqhc3NTVIBc8W3hQHq3c76g2PKybyPYHy19FoeeUBg+G4tggowSHU5eRL9bxl3k/k1dMnEsMmmlk= 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 1565276301296813.0506895527802; Thu, 8 Aug 2019 07:58:21 -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 2AECE30A00DD; Thu, 8 Aug 2019 14:58:20 +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 048F11001B02; Thu, 8 Aug 2019 14:58:20 +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 BD58D8354E; Thu, 8 Aug 2019 14:58:19 +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 x78Eu5G9022869 for ; Thu, 8 Aug 2019 10:56:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 618C25D9CC; Thu, 8 Aug 2019 14:56:05 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27A505DAA0; Thu, 8 Aug 2019 14:55:58 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:54:55 +0400 Message-Id: <20190808145514.20789-5-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 04/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.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.43]); Thu, 08 Aug 2019 14:58:20 +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. This is not strictly necessary for swtpm, but the following patches are going to reuse qemuExtDeviceLogCommand(). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- src/qemu/qemu_extdevice.c | 35 ++++++++++------------------------- src/qemu/qemu_extdevice.h | 5 +++-- src/qemu/qemu_tpm.c | 4 ++-- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index af52466421..0aa050cb0a 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: * diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h index 5a53c79f38..cdd20c28ef 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, diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 98fe8a38b4..7537091e90 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -834,7 +834,7 @@ qemuExtTPMCleanupHost(virDomainDefPtr def) static int qemuExtTPMStartEmulator(virQEMUDriverPtr driver, virDomainObjPtr vm, - qemuDomainLogContextPtr logCtxt, + qemuDomainLogContextPtr logCtxt ATTRIBUTE_UNUSED, bool incomingMigration) { int ret =3D -1; @@ -863,7 +863,7 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver, incomingMigration))) goto cleanup; =20 - if (qemuExtDeviceLogCommand(logCtxt, cmd, "TPM Emulator") < 0) + if (qemuExtDeviceLogCommand(driver, vm, cmd, "TPM Emulator") < 0) goto cleanup; =20 virCommandSetErrorBuffer(cmd, &errbuf); --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276326; cv=none; d=zoho.com; s=zohoarc; b=MrkNQW9cXwCUXPsOrcXfWMNw2f++zkWLKOcgO5uuB7+dNe1a6LhuTfUpLn365MpTWD1qRIsZLxCrX7QLn+uSisK044c88bv5uGKas7bdneRoUuXUqMOCj2Xv9soQs0wakxwgCwqSyqmuk4uB710vuYUMtVB1ypHRna4OX5bo1lI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276326; 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=l+SEAugKlusyPfWhThFzkzFJ3Lit/EYSZKL5HXvABj8=; b=nTcmGmtxTIy5bsvPTBWO5obl5nOqMoxQ24ZI8TFZsiLkC0MMUt5cJp6LJMK5+UuhuzjjuwMsyH8jGfDNoLYoeWLGucoubXXKmBgZ1XrQhLJzZAjSJmWCR6Xp5WsdXE5tEh7+J8+Z/Mj7Csb1CafdijR0vuvZpNo9L7ZfeSvl4/Q= 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 1565276326394649.2866286842509; Thu, 8 Aug 2019 07:58:46 -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 18339305B41C; Thu, 8 Aug 2019 14:58:45 +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 E37D560A35; Thu, 8 Aug 2019 14:58:44 +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 A0446180BA98; Thu, 8 Aug 2019 14:58:44 +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 x78EuHjH022882 for ; Thu, 8 Aug 2019 10:56:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id DEDBE60A35; Thu, 8 Aug 2019 14:56:17 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D074608AB; Thu, 8 Aug 2019 14:56:11 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:54:56 +0400 Message-Id: <20190808145514.20789-6-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 08 Aug 2019 14:58:45 +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 | 6 ++++++ src/qemu/qemu_capabilities.h | 1 + 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, 14 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 405bc3f288..4cb135cd93 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -536,6 +536,7 @@ VIR_ENUM_IMPL(virQEMUCaps, =20 /* 335 */ "bochs-display", + "net-socket-dgram", ); =20 =20 @@ -4389,6 +4390,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 d7c6df20c7..c8b9970eb3 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_DEVICE_BOCHS_DISPLAY, /* -device bochs-display */ + QEMU_CAPS_NET_SOCKET_DGRAM, /* -net socket,fd=3D with dgram socket */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_4.0.0.aarch64.xml index 8fe369f518..f9eccf0596 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml @@ -164,6 +164,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 2df230c4f7..8b96b85d4e 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml @@ -169,6 +169,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 f4acda457a..704cf612d6 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml @@ -167,6 +167,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 e71d83ee06..946484db8c 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml @@ -167,6 +167,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 1d44a5a1ba..53b1ff6e11 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -206,6 +206,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 f336aeb48c..6ad8194eb5 100644 --- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml @@ -208,6 +208,7 @@ + 4000050 0 43100759 --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276309; cv=none; d=zoho.com; s=zohoarc; b=n/XFJNqs4ZDN5+gJOzbgoAR7PNXIKB0dBt2ODp96wITNZTzYpoqPDHZxAvSguDFTqCvBzNbmljmWrXoaHiyxVZdx/m7oLWqzkGP/AhgDJId2HMApYtChmm+aqV+RA/eaSS39WSFFFc+MRkI/wZZnRuA2eymdeF2Gcd6mN6rWj/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276309; 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=VOaQJ6FFo84c5IsyjZ+heJYfJBPlin9EDivtkkiHa6U=; b=W1uOs9lG6bRVvVn6xrflA5gD9yJqjzUk7FJo3yLoK7zTSBYaPeNOASApHc71wR2S/gqhM49uPQTMrLwvWWoub6Z0JPnXd04q3NDuihM4mSSxhb/HKt0g775h6d55jHSmbcZOkLLFQPYPqfXtuAjKr/NFUMcMyAHA14uiAufuwBI= 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 1565276309615513.185447680165; Thu, 8 Aug 2019 07:58: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 AD0BC30923CA; Thu, 8 Aug 2019 14:58: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 802E260318; Thu, 8 Aug 2019 14:58: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 33C5683550; Thu, 8 Aug 2019 14:58:23 +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 x78EuTB9022896 for ; Thu, 8 Aug 2019 10:56:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F8EC5D9DC; Thu, 8 Aug 2019 14:56:29 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id E31F95D9CC; Thu, 8 Aug 2019 14:56:23 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:54:57 +0400 Message-Id: <20190808145514.20789-7-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 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.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.48]); Thu, 08 Aug 2019 14:58:24 +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 Reviewed-by: Michal Privoznik --- 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 4cb135cd93..f698034cb5 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -537,6 +537,7 @@ VIR_ENUM_IMPL(virQEMUCaps, /* 335 */ "bochs-display", "net-socket-dgram", + "dbus-vmstate", ); =20 =20 @@ -1127,6 +1128,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[= ] =3D { { "virtio-serial-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIO= NAL }, { "max-x86_64-cpu", QEMU_CAPS_X86_MAX_CPU }, { "bochs-display", QEMU_CAPS_DEVICE_BOCHS_DISPLAY }, + { "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 c8b9970eb3..670978b8ba 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -518,6 +518,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ /* 335 */ QEMU_CAPS_DEVICE_BOCHS_DISPLAY, /* -device bochs-display */ 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.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276329; cv=none; d=zoho.com; s=zohoarc; b=IGPeisU48YqM7ZTQeeunhsYpcb7wDJu/QUm8BmAAytj0Ku+J9QhllzNcFaWkjd0SOLd6wQ9wI0wc2dSwyu32U6nTVH6Of9l6J/H6Cy5SxvrQMDQPJDPPnAJnZC3a3nZVgFzLBv2mJnziq8G9Z/ec66EpvJwaCR8VwIlvBTdwozg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276329; 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=XGPaMitpVfSAMFbNcUM9j7zFh8t1BjUseLji2E0k9O0=; b=gGfd3JgKKc5hKLdJy8Qk08A3kjAt3f17gmE5tCuxqJahzlojNB5ub0pcqykMLYnq3pX8VPDZEhsABcMK0gHeJUci1sQkWKgJjgElh3hzZKCKVOw1hO04sQSEtrQeUOth5N5y/F8wltoEiSAF5xALks9EkNxtYm7W7tzSnMKdwFc= 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 1565276329876464.7985514234092; Thu, 8 Aug 2019 07:58:49 -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 BB823970EC; Thu, 8 Aug 2019 14:58:48 +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 8BE0860600; Thu, 8 Aug 2019 14:58: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 4DCCB180BAA4; Thu, 8 Aug 2019 14:58:48 +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 x78EudJv022954 for ; Thu, 8 Aug 2019 10:56:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8BCFE5C219; Thu, 8 Aug 2019 14:56:39 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29EF45C205; Thu, 8 Aug 2019 14:56:33 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:54:58 +0400 Message-Id: <20190808145514.20789-8-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 07/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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 08 Aug 2019 14:58:49 +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 Reviewed-by: Michal Privoznik --- 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 1ed56457b1..f8d740979d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7400,8 +7400,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 @@ -7477,6 +7475,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.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276333; cv=none; d=zoho.com; s=zohoarc; b=CxC9WzI6dj82Wz59gysXZcTRAYMb2uK1mn08iiRMhZ63Tqgu/+bTMv8KhypknKX/Xx/eOq5G36Q+BrQwhSnXBy5BN6OQraa4HqzbTPPxeyszBzdaCkc+i3nSG4bMqwN6jHPlhjmaGAOOjVEKSRHhmeWI4PTmkMMJr9s821L5avc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276333; 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=bIx0VRBlwoGcpKAEh6/TJYnjTb/S79uKxYhaIUhPUaU=; b=e6gaO7qk5gIkorHVLPyMfBd8jUznMkGOYLrHzCLvsjalJkIhrXaXKh8SWqmvIpdxi9DJeXKthPA7Ux2By21tCLNyjT9Dk6IadlNJQ2XsKNSU49N43tSkkSumQWx8v7aHQCJUsAq5DQIz+rlN07rCVLEAlplaDYrRnzSf/OPwJms= 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 1565276333687286.2617920545505; Thu, 8 Aug 2019 07:58:53 -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 81B9D2D1EF1; Thu, 8 Aug 2019 14:58:52 +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 092831D9; Thu, 8 Aug 2019 14:58:52 +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 A73CF8354B; Thu, 8 Aug 2019 14:58:51 +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 x78Euo3V022967 for ; Thu, 8 Aug 2019 10:56:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD61C5D9E1; Thu, 8 Aug 2019 14:56:50 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D7CF5D9CC; Thu, 8 Aug 2019 14:56:43 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:54:59 +0400 Message-Id: <20190808145514.20789-9-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 08/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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 08 Aug 2019 14:58:53 +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 Reviewed-by: Michal Privoznik --- 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 3cd6d9bd3d..f8b53e06b3 100644 --- a/src/qemu/qemu_security.c +++ b/src/qemu/qemu_security.c @@ -632,3 +632,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.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276284; cv=none; d=zoho.com; s=zohoarc; b=Jn7VK4FP+blNaSwW1+Dhbc+kTrRq+aDGIxwm/g94j1RF+Jbsr+BLrWXF13sYdZiZKwV98nXuJWesnqsFb9Lb5VlmpYT7PIoFmL4rnEaOABCt0LyAqZkj7AsNRYOKoK5a8qrGVC9Qpd245zSN+Xq9YZ3dN3ikWEAE3x+fcT/HdiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276284; 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=QYRfRou8IqECyG66d/rPpuao3A7KnFdtjLHr1fxhS80=; b=cMvJ6Z9rcDsVCrSQw4ZrP09k2MBCTOA6B7Y14O+6bv1WGIAus3roM6O94ZkgooJ8tzSvwOvna9arHmDpxpe7vrxUe4HCDmx2J/+Q8C5iboFDo3+TMRiMp2tUN7jwNiKICX9rGJQ4o2icE5pNxARyu3HA5sR/JlyLaZXvOkdyO98= 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 1565276284055385.5540170321931; Thu, 8 Aug 2019 07:58:04 -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 821E030A7BA7; Thu, 8 Aug 2019 14:58: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 5849D3DB4; Thu, 8 Aug 2019 14:58:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0056383545; Thu, 8 Aug 2019 14:58:01 +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 x78Ev4d9023304 for ; Thu, 8 Aug 2019 10:57:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 70196F6E8; Thu, 8 Aug 2019 14:57:04 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A8F2194BB; Thu, 8 Aug 2019 14:56:55 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:00 +0400 Message-Id: <20190808145514.20789-10-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 09/23] qemu: add dbus-vmstate 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.47]); Thu, 08 Aug 2019 14:58:03 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Add dbusVMStates to keep a list of dbus-vmstate objects needed for migration. They are populated on the command line during start or qemuDBusVMStateAdd/Remove() will hotplug them as needed. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- src/qemu/Makefile.inc.am | 2 + src/qemu/qemu_alias.c | 17 ++++++++ src/qemu/qemu_alias.h | 3 ++ src/qemu/qemu_command.c | 83 +++++++++++++++++++++++++++++++++++ src/qemu/qemu_command.h | 3 ++ src/qemu/qemu_dbus.c | 94 ++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_dbus.h | 42 ++++++++++++++++++ src/qemu/qemu_domain.c | 14 ++++++ src/qemu/qemu_domain.h | 2 + src/qemu/qemu_hotplug.c | 75 ++++++++++++++++++++++++++++++++ src/qemu/qemu_hotplug.h | 11 +++++ 11 files changed, 346 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..94dd0e56ff 100644 --- a/src/qemu/Makefile.inc.am +++ b/src/qemu/Makefile.inc.am @@ -13,6 +13,8 @@ QEMU_DRIVER_SOURCES =3D \ qemu/qemu_capabilities.h \ qemu/qemu_command.c \ qemu/qemu_command.h \ + qemu/qemu_dbus.c \ + qemu/qemu_dbus.h \ qemu/qemu_domain.c \ qemu/qemu_domain.h \ qemu/qemu_domain_address.c \ diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 585cc972ba..fc5246bc7f 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -843,3 +843,20 @@ qemuDomainGetUnmanagedPRAlias(const char *parentalias) =20 return ret; } + +char * +qemuAliasDBusVMStateFromId(const char *id) +{ + char *ret; + int i; + + if (virAsprintf(&ret, "dbus-vms-%s", id) < 0) + return NULL; + + for (i =3D 0; ret[i]; i++) { + if (ret[i] =3D=3D ':') + ret[i] =3D '_'; + } + + return ret; +} diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h index aaac09a1d1..ae2fce16bc 100644 --- a/src/qemu/qemu_alias.h +++ b/src/qemu/qemu_alias.h @@ -95,3 +95,6 @@ char *qemuAliasChardevFromDevAlias(const char *devAlias) const char *qemuDomainGetManagedPRAlias(void); =20 char *qemuDomainGetUnmanagedPRAlias(const char *parentalias); + +char *qemuAliasDBusVMStateFromId(const char *id) + ATTRIBUTE_NONNULL(1); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 71a36ff63a..4357aa2fe1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -27,6 +27,7 @@ #include "qemu_interface.h" #include "qemu_alias.h" #include "qemu_security.h" +#include "qemu_dbus.h" #include "qemu_block.h" #include "cpu/cpu.h" #include "dirname.h" @@ -10386,6 +10387,85 @@ 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(const char *id, + const char *addr) +{ + VIR_AUTOFREE(char *) alias =3D qemuAliasDBusVMStateFromId(id); + + if (!alias) + return NULL; + + return qemuBuildDBusVMStateInfoPropsInternal(alias, addr); +} + + +typedef struct qemuBuildDBusVMStateCommandLineData { + virCommandPtr cmd; +} qemuBuildDBusVMStateCommandLineData; + + +static int +qemuBuildDBusVMStateCommandLineEach(void *payload, + const void *id, + void *user_data) +{ + qemuBuildDBusVMStateCommandLineData *data =3D user_data; + qemuDBusVMStatePtr vms =3D payload; + VIR_AUTOCLEAN(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + VIR_AUTOPTR(virJSONValue) props =3D NULL; + + if (!(props =3D qemuBuildDBusVMStateInfoProps(id, vms->addr))) + return -1; + + if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0) + return -1; + + virCommandAddArg(data->cmd, "-object"); + virCommandAddArgBuffer(data->cmd, &buf); + + return 0; +} + +static int +qemuBuildDBusVMStateCommandLine(virCommandPtr cmd, + qemuDomainObjPrivatePtr priv) +{ + qemuBuildDBusVMStateCommandLineData data =3D { + .cmd =3D cmd, + }; + + if (virHashSize(priv->dbusVMStates) =3D=3D 0) + return 0; + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("dbus-vmstate object is not supported by this QEM= U binary")); + return 0; + } + + if (virHashForEach(priv->dbusVMStates, qemuBuildDBusVMStateCommandLine= Each, &data) < 0) + return -1; + + return 0; +} + + /** * qemuBuildCommandLineValidate: * @@ -10630,6 +10710,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildMasterKeyCommandLine(cmd, priv) < 0) goto error; =20 + if (qemuBuildDBusVMStateCommandLine(cmd, priv) < 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 7e2dc5a60a..3a957c52fc 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -62,6 +62,9 @@ virJSONValuePtr qemuBuildPRManagedManagerInfoProps(qemuDo= mainObjPrivatePtr priv) int qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo, virJSONValuePtr *propsret); =20 +virJSONValuePtr qemuBuildDBusVMStateInfoProps(const char *id, + const char *addr); + /* Generate the object properties for a tls-creds-x509 */ int qemuBuildTLSx509BackendProps(const char *tlspath, bool isListen, diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c new file mode 100644 index 0000000000..76cd3bd346 --- /dev/null +++ b/src/qemu/qemu_dbus.c @@ -0,0 +1,94 @@ +/* + * qemu_dbus.c: QEMU DBus-related helpers + * + * 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_hotplug.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"); + + +qemuDBusVMStatePtr +qemuDBusVMStateNew(const char *id, const char *addr) +{ + VIR_AUTOPTR(qemuDBusVMState) self; + + if (VIR_ALLOC(self) < 0) + return NULL; + + if (VIR_STRDUP(self->id, id) < 0) + return NULL; + + if (VIR_STRDUP(self->addr, addr) < 0) + return NULL; + + VIR_RETURN_PTR(self); +} + + +void +qemuDBusVMStateFree(qemuDBusVMStatePtr self) +{ + VIR_FREE(self->id); + VIR_FREE(self->addr); + VIR_FREE(self); +} + + +int +qemuDBusVMStateAdd(virQEMUDriverPtr driver, virDomainObjPtr vm, + const char *id, const char *addr, bool hot) +{ + qemuDBusVMStatePtr d =3D qemuDBusVMStateNew(id, addr); + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + if (virHashAddEntry(QEMU_DOMAIN_PRIVATE(vm)->dbusVMStates, id, d) < 0)= { + qemuDBusVMStateFree(d); + return -1; + } + + if (hot && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE) && + qemuDomainAttachDBusVMState(driver, vm, id, addr, QEMU_ASYNC_JOB_N= ONE) < 0) + return -1; + + return 0; +} + + +void +qemuDBusVMStateRemove(virQEMUDriverPtr driver, virDomainObjPtr vm, + const char *id, bool hot) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + if (virHashRemoveEntry(QEMU_DOMAIN_PRIVATE(vm)->dbusVMStates, id) < 0 = || + (hot && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE) && + qemuDomainDetachDBusVMState(driver, vm, id, QEMU_ASYNC_JOB_NONE) = < 0)) + VIR_ERROR("Failed to remove vmstate id"); +} diff --git a/src/qemu/qemu_dbus.h b/src/qemu/qemu_dbus.h new file mode 100644 index 0000000000..68ef6d1abf --- /dev/null +++ b/src/qemu/qemu_dbus.h @@ -0,0 +1,42 @@ +/* + * qemu_dbus.c: QEMU DBus-related helpers + * + * 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" + +typedef struct _qemuDBusVMState qemuDBusVMState; +typedef qemuDBusVMState *qemuDBusVMStatePtr; +struct _qemuDBusVMState { + char *id; + char *addr; +}; + + +qemuDBusVMStatePtr qemuDBusVMStateNew(const char *id, const char *addr); + +void qemuDBusVMStateFree(qemuDBusVMStatePtr self); + +int qemuDBusVMStateAdd(virQEMUDriverPtr driver, virDomainObjPtr vm, + const char *id, const char *addr, bool hot); + +void qemuDBusVMStateRemove(virQEMUDriverPtr driver, virDomainObjPtr vm, + const char *id, bool hot); + +VIR_DEFINE_AUTOPTR_FUNC(qemuDBusVMState, qemuDBusVMStateFree); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0555caa6ab..806dbfd1f8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -26,6 +26,7 @@ #include "qemu_block.h" #include "qemu_cgroup.h" #include "qemu_command.h" +#include "qemu_dbus.h" #include "qemu_process.h" #include "qemu_capabilities.h" #include "qemu_migration.h" @@ -1961,6 +1962,14 @@ qemuDomainSetPrivatePaths(virQEMUDriverPtr driver, } =20 =20 +static void +dbusVMStateHashFree(void *opaque, + const void *name ATTRIBUTE_UNUSED) +{ + qemuDBusVMStateFree(opaque); +} + + static void * qemuDomainObjPrivateAlloc(void *opaque) { @@ -1981,6 +1990,9 @@ qemuDomainObjPrivateAlloc(void *opaque) if (!(priv->blockjobs =3D virHashCreate(5, virObjectFreeHashData))) goto error; =20 + if (!(priv->dbusVMStates =3D virHashCreate(5, dbusVMStateHashFree))) + goto error; + priv->migMaxBandwidth =3D QEMU_DOMAIN_MIG_BANDWIDTH_MAX; priv->driver =3D opaque; =20 @@ -2052,6 +2064,7 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr= priv) qemuDomainObjResetAsyncJob(priv); =20 virHashRemoveAll(priv->blockjobs); + virHashRemoveAll(priv->dbusVMStates); } =20 =20 @@ -2084,6 +2097,7 @@ qemuDomainObjPrivateFree(void *data) qemuDomainMasterKeyFree(priv); =20 virHashFree(priv->blockjobs); + virHashFree(priv->dbusVMStates); =20 VIR_FREE(priv); } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index b76d3cace9..851fb98f42 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -392,6 +392,8 @@ struct _qemuDomainObjPrivate { =20 /* running block jobs */ virHashTablePtr blockjobs; + + virHashTablePtr dbusVMStates; }; =20 #define QEMU_DOMAIN_PRIVATE(vm) \ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d8be63b71c..028921fb47 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -417,6 +417,81 @@ qemuHotplugRemoveManagedPR(virQEMUDriverPtr driver, } =20 =20 +/** + * qemuDomainAttachDBusVMState: + * @driver: QEMU driver object + * @vm: domain object + * @id + * @addr + * @asyncJob: asynchronous job identifier + * + * Add dbus-vmstate object. + * + * Returns: 0 on success, -1 on error. + */ +int +qemuDomainAttachDBusVMState(virQEMUDriverPtr driver, + virDomainObjPtr vm, + const char *id, + const char *addr, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + VIR_AUTOPTR(virJSONValue) props =3D NULL; + int ret; + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("dbus-vmstate object is not supported by this QEM= U binary")); + return -1; + } + + if (!(props =3D qemuBuildDBusVMStateInfoProps(id, addr))) + return -1; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + ret =3D qemuMonitorAddObject(priv->mon, &props, NULL); + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + return -1; + + return ret; +} + + +/** + * qemuDomainDetachDBusVMState: + * @driver: QEMU driver object + * @vm: domain object + * @asyncJob: asynchronous job identifier + * + * Remove dbus-vmstate object from @vm. + * + * Returns: 0 on success, -1 on error. + */ +int +qemuDomainDetachDBusVMState(virQEMUDriverPtr driver, + virDomainObjPtr vm, + const char *id, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + int ret; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + ret =3D qemuMonitorDelObject(priv->mon, qemuAliasDBusVMStateFromId(id)= ); + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + return -1; + + return ret; +} + + /** * qemuDomainChangeMediaBlockdev: * @driver: qemu driver structure diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 896e6c7b98..6d2cd34dbc 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -150,3 +150,14 @@ int qemuDomainSetVcpuInternal(virQEMUDriverPtr driver, virDomainDefPtr persistentDef, virBitmapPtr vcpus, bool state); + +int qemuDomainAttachDBusVMState(virQEMUDriverPtr driver, + virDomainObjPtr vm, + const char *id, + const char *addr, + qemuDomainAsyncJob asyncJob); + +int qemuDomainDetachDBusVMState(virQEMUDriverPtr driver, + virDomainObjPtr vm, + const char *id, + qemuDomainAsyncJob asyncJob); --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276289; cv=none; d=zoho.com; s=zohoarc; b=Ihy1qXyNhK6ioDAbajQVIJKXyFeEhtl4UmUb27y1JlHwBap35U0ekA2X64kEDiWFfIRGnyj3ppFaHTec1xwYMTlvx2p+J5fHCYv93dqeTP8nFeXyJB7k6xIKb13xcHo/QMv2tvUHAYtwZb4lgqC5be/F3/nHEgIwtVHrf1e396g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276289; 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=A61c0PAYxwymMgZ2oSlrA38jiaUO/dwXCnjMm9QYgIw=; b=oljBPUUrs+X64rMZXNdYmzKANajyJELCV+534HWB+el8NGBjLFrKCy877kEgfmrl7Ws9kYR4IjIt1EnZwt7jGHFZ6uFaez8cE5JvHik4r6TKX0bPi4M58lFh0RTINAPcnnOXBusnpxk8pkwUPoZSF8Y1Bjmc/jByf5o/nu8IQVE= 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 1565276289364780.8951259179848; Thu, 8 Aug 2019 07:58:09 -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 F152D7BDB1; Thu, 8 Aug 2019 14:58:07 +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 C62E4600F8; Thu, 8 Aug 2019 14:58: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 8A3FA83549; Thu, 8 Aug 2019 14:58: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 x78EvEse023315 for ; Thu, 8 Aug 2019 10:57:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 70E2860A35; Thu, 8 Aug 2019 14:57:14 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21FCA608AB; Thu, 8 Aug 2019 14:57:08 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:01 +0400 Message-Id: <20190808145514.20789-11-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 10/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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 08 Aug 2019 14:58:08 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- 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 0456369d55..fb0904177f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2454,6 +2454,7 @@ virDomainNetDefFree(virDomainNetDefPtr def) if (!def) return; virDomainNetDefClear(def); + virObjectUnref(def->privateData); VIR_FREE(def); } =20 @@ -11441,7 +11442,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; @@ -14337,6 +14338,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 57ca2a8ad1..9bd196b53c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1018,6 +1018,7 @@ struct _virDomainNetDef { unsigned int mtu; virNetDevCoalescePtr coalesce; virDomainVirtioOptionsPtr virtio; + virObjectPtr privateData; }; =20 typedef enum { @@ -2711,6 +2712,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 @@ -2894,6 +2896,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.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276308; cv=none; d=zoho.com; s=zohoarc; b=E1bmN6nnFMo8H6I/Z2MxWdifF4eNaSoQQm2LkQm1pvlrc1ZLIb71jF0I4g3Wm2pKNgLOAXU1mWQBHvavrGdYxtcZIcG+1MBahf8wbredNr+xk19RRb5TEyZU0jTZzkYo9spp0mKfc2OGGq+0JHPYPXYgwi5GZM5esecoeIW4Z/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276308; 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=n0p29mxX0un3Ql/BIvAhIXCDEkv+/w3xwa+eatWNh+s=; b=M7HL4nY44f/AVyZ/BpUj7xG/MnskRI/oXvUl2omhIRCjVqbz28lJvxzoxoXez3tCpBqLFze8BAMQ1l4AvhbaiyTlwIYtdplJOZ4QnbIqS6fPAll4GfJEyjCj2pkOyoauYdBDRv4jp+Vi/Wx9p+Ek5CcKA4qDTZ4SkWA/IxdCVwM= 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 1565276308540180.9584562849643; Thu, 8 Aug 2019 07:58: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 59F4F3090FED; Thu, 8 Aug 2019 14:58:27 +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 32C56579C; Thu, 8 Aug 2019 14:58:27 +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 ED8FC180BA98; Thu, 8 Aug 2019 14:58:26 +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 x78EvO8A023327 for ; Thu, 8 Aug 2019 10:57:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D78A5D772; Thu, 8 Aug 2019 14:57:24 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F5235D721; Thu, 8 Aug 2019 14:57:18 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:02 +0400 Message-Id: <20190808145514.20789-12-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 11/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.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]); Thu, 08 Aug 2019 14:58:27 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- 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 806dbfd1f8..7315fe103e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1269,6 +1269,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 @@ -3428,6 +3466,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 851fb98f42..560b01d80a 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -509,6 +509,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.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276337; cv=none; d=zoho.com; s=zohoarc; b=KoVXeaXwS1cPmoLOZRj6K3Fndz4Qeqq6smfA5j5NoD5NxsmOQhneyEs4PwFw2sUSJ1UVbhGlRj+QXZT0JfGzWJtWunsLM9ZdLQBinhDbPBD2Zwet9h19G2u3AqH+cVjaQKAVxiMkJsJIfBOdMkna5ESoZWanY1+N3m3n0r3x0jk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276337; 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=zlOQECOFQUgOKURizBKWabmGag5gbWvK9t+FD98R8C0=; b=FwS/aqKV4N5KqX0lOGiU57dfos1ftZ54unPtuGGZKvVwnO1J/hiOxRcZjE7OPPakMfdYqc5ncM/ri2fm5MMdVQr6SANmekOWW+JqcBOJkSjMLaNTM1rez+D0gQxHhDvcKjG/7qaKOQH0TCLc3cMDjMea+94ZMQrdWRUisx05crU= 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 1565276337814477.03235192235195; Thu, 8 Aug 2019 07:58:57 -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 900EB314570B; Thu, 8 Aug 2019 14:58:56 +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 66F0C5C72E; Thu, 8 Aug 2019 14:58:56 +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 2A653180BAA6; Thu, 8 Aug 2019 14:58:56 +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 x78EvZu0023340 for ; Thu, 8 Aug 2019 10:57:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0A78E3DB4; Thu, 8 Aug 2019 14:57:35 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AC65194B9; Thu, 8 Aug 2019 14:57:28 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:03 +0400 Message-Id: <20190808145514.20789-13-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 12/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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 08 Aug 2019 14:58:57 +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 Reviewed-by: Michal Privoznik --- 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..a1d2c66bba 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_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 2a99a0c55f..7d7844dc09 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 "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 8cabeccacb..b3a3428e4c 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -833,6 +833,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" + # 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 2953893337..4b84cb6dea 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -282,7 +282,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->slirpHelperName, QEMU_SLIRP_HELPER) < 0) goto error; =20 cfg->clearEmulatorCapabilities =3D true; @@ -373,6 +374,7 @@ static void virQEMUDriverConfigDispose(void *obj) VIR_FREE(cfg->hugetlbfs); VIR_FREE(cfg->bridgeHelperName); VIR_FREE(cfg->prHelperName); + VIR_FREE(cfg->slirpHelperName); =20 VIR_FREE(cfg->saveImageFormat); VIR_FREE(cfg->dumpImageFormat); @@ -669,6 +671,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 (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 0cbddd7a9c..a85ae50e14 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -153,6 +153,7 @@ struct _virQEMUDriverConfig { =20 char *bridgeHelperName; char *prHelperName; + 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 b3b44d42d9..d686d248ae 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -104,6 +104,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" } { "swtpm_user" =3D "tss" } { "swtpm_group" =3D "tss" } { "capability_filters" --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276292; cv=none; d=zoho.com; s=zohoarc; b=arurm2ftQPM53wxvcN3kEkKMMFbRrp9kgl0s85EftZNrxbc9Tzl3+y9HN0BGI9OF+PUK8eBPu2dzUuG65/QV2Z7f15d7sin76ahIP83oGhQWcZ8OjEBDPbguxM41TfFD4fgPS9F3lr/7qULTNlvWb0PXsta0zaXsxMIpRhpyw48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276292; 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=dqqsf/R7dkpp67WfIKc9GMDpMXO+SJEM8yI4KldZbM0=; b=eQXLExtCw1TlQgFutfL3xb1+BlAaH6UhC0kWRybSAnG4qDBx++2tb3XWtEWQbEel952BV71HcoBytGl09RhLuJjdIffzN4KSDezT3f1kDgdaWMgjtLa57Mv1is7bXbzcRkePG3xeHBhPx2CUD0X/6umTwQKa/0m79kgGPU5IDvk= 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 1565276292699774.124260455511; Thu, 8 Aug 2019 07:58:12 -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 819EE30A5687; Thu, 8 Aug 2019 14:58: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 49FF75DAA0; Thu, 8 Aug 2019 14:58: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 03A888354B; Thu, 8 Aug 2019 14:58:11 +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 x78EveMS023354 for ; Thu, 8 Aug 2019 10:57:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id C0721F6EE; Thu, 8 Aug 2019 14:57:40 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE139166A7; Thu, 8 Aug 2019 14:57:39 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:04 +0400 Message-Id: <20190808145514.20789-14-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 13/23] qemu-conf: add slirp state dir 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.47]); Thu, 08 Aug 2019 14:58:12 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- src/qemu/qemu_conf.c | 4 ++++ src/qemu/qemu_conf.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 4b84cb6dea..7d2e84b5bb 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -216,6 +216,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool priv= ileged) if (virAsprintf(&cfg->swtpmStateDir, "%s/swtpm", cfg->stateDir) < = 0) goto error; =20 + if (virAsprintf(&cfg->slirpStateDir, "%s/slirp", cfg->stateDir) < = 0) + goto error; + if (!(cfg->configBaseDir =3D virGetUserConfigDirectory())) goto error; =20 @@ -335,6 +338,7 @@ static void virQEMUDriverConfigDispose(void *obj) VIR_FREE(cfg->swtpmLogDir); VIR_FREE(cfg->stateDir); VIR_FREE(cfg->swtpmStateDir); + VIR_FREE(cfg->slirpStateDir); =20 VIR_FREE(cfg->libDir); VIR_FREE(cfg->cacheDir); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a85ae50e14..8473d6d4ca 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -96,6 +96,7 @@ struct _virQEMUDriverConfig { char *swtpmLogDir; char *stateDir; char *swtpmStateDir; + char *slirpStateDir; /* These two directories are ones QEMU processes use (so must match * the QEMU user/group */ char *libDir; --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276312; cv=none; d=zoho.com; s=zohoarc; b=njighjhaNtMTVsU/QdtN79GEZchDkSVm2zxVaSKoAe42Rp0+91Q1VphUcXKHc5IBOcY9eX5YHoEepHWCIWYC9ZH4YSqCxkUx0sUoIlknvWAQ9hUDglq6J96CtfIX8T9xQCwtN3oS7Xh+rMcchLIV6EJAHJ9QK9Kwa50Zmmz3nBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276312; 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=ychn8+PJTShCRRGqZfE+N08Y6LHpRVxcsuJG/ruW7Mk=; b=hOGMOKMY0VA/EtT39Y2/3L2SgHX7kcq/Dym9OWkr3JrJ96CJOE+13oR6CD55UVFupA0raR0NBpB+fLsyIhhkRUVrpxIbEeaICst6y9qymnrwz4lto/wOE7kNREq3vzOOq833DoqKzRkBKoYUrBVaZ0urIwyZdXFZDNEww04OLDs= 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 1565276312397733.1710167191889; Thu, 8 Aug 2019 07:58:32 -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 1B9106908B; Thu, 8 Aug 2019 14:58:31 +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 DAF205B6A5; Thu, 8 Aug 2019 14:58:30 +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 9490183552; Thu, 8 Aug 2019 14:58:30 +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 x78EvqLo023365 for ; Thu, 8 Aug 2019 10:57:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id E45F91F4; Thu, 8 Aug 2019 14:57:52 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC0AB5DAA0; Thu, 8 Aug 2019 14:57:44 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:05 +0400 Message-Id: <20190808145514.20789-15-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 14/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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 08 Aug 2019 14:58:31 +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 Reviewed-by: Michal Privoznik --- src/qemu/Makefile.inc.am | 2 + src/qemu/qemu_domain.h | 4 + src/qemu/qemu_slirp.c | 448 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_slirp.h | 81 +++++++ 4 files changed, 535 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 94dd0e56ff..505b418fa5 100644 --- a/src/qemu/Makefile.inc.am +++ b/src/qemu/Makefile.inc.am @@ -58,6 +58,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 \ $(NULL) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 560b01d80a..7293c87d7c 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -509,6 +509,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..36370b6be0 --- /dev/null +++ b/src/qemu/qemu_slirp.c @@ -0,0 +1,448 @@ +/* + * 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", + "dbus-p2p", + "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; +} + + +static char * +qemuSlirpGetDBusAddress(const char *stateDir, + const char *shortName, + const char *alias) +{ + char *name =3D NULL; + + if (virAsprintf(&name, "unix:path=3D%s/%s-%s-slirp", stateDir, shortNa= me, alias) < 0) + return NULL; + + return name; +} + + +void +qemuSlirpStop(qemuSlirpPtr slirp, + virDomainObjPtr vm, + virQEMUDriverPtr driver, + virDomainNetDefPtr net, + bool hot) +{ + 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(driver, vm, id, hot); + + 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, + bool hotplug, + 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 *) dbus_addr =3D NULL; + VIR_AUTOFREE(char *) id =3D NULL; + VIR_AUTOFREE(char *) shortName =3D virDomainDefGetShortName(vm->def); + size_t i; + virTimeBackOffVar timebackoff; + const unsigned long long timeout =3D 500 * 1000; /* ms */ + const char *dbus_path =3D NULL; + 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_P2P)) { + id =3D qemuSlirpGetDBusVMStateId(net); + dbus_addr =3D qemuSlirpGetDBusAddress(cfg->stateDir, + shortName, net->info.alias); + if (!id || !dbus_addr) { + return -1; + } + + dbus_path =3D dbus_addr + strlen("unix:path=3D"); + + if (unlink(dbus_path) < 0 && errno !=3D ENOENT) { + virReportSystemError(errno, _("Unable to unlink %s"), dbus_pat= h); + return -1; + } + + virCommandAddArgFormat(cmd, "--dbus-id=3D%s", id); + + virCommandAddArgFormat(cmd, "--dbus-p2p=3D%s", dbus_addr); + + if (incoming && + qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_MIGRATE)) + 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; + } + + if (dbus_path) { + while (virTimeBackOffWait(&timebackoff)) { + if (!virFileExists(dbus_path)) + continue; + break; + } + } + + if (qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_MIGRATE)) { + if (qemuDBusVMStateAdd(driver, vm, id, dbus_addr, hotplug) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to register slirp migration")); + return -1; + } + } + + 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..f44edce543 --- /dev/null +++ b/src/qemu/qemu_slirp.h @@ -0,0 +1,81 @@ +/* + * 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_DBUS_P2P, + 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, + bool hot, + qemuProcessIncomingDefPtr incoming); + +void qemuSlirpStop(qemuSlirpPtr slirp, + virDomainObjPtr vm, + virQEMUDriverPtr driver, + virDomainNetDefPtr net, + bool hot); + +int qemuSlirpGetFD(qemuSlirpPtr slirp); + +VIR_DEFINE_AUTOPTR_FUNC(qemuSlirp, qemuSlirpFree); --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276315; cv=none; d=zoho.com; s=zohoarc; b=bJTPDOYNsqv8mqWpgt14GndNlnA8HePCddFjsk+MDze5zVDcHklPxKv/1Z9si0H4gCU998O48fRgUX2xat0EnGIH09gZfWVhlTbPOheyGjlw1CPud7LryBSeD3izfQXdhnZ4TLYndbqzfgv76/wnDbSKY8UpLWP39u/WH4ZOArQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276315; 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=sa8ndZY6MmR1cBzK0mMLTYl3PfBLQZLasJUpMMumI7I=; b=e6fPc67wBN3CsucZpGRT0oLoIKLCCiEJNICuESxspUc6TbLJekuEApk/pwvKu4Qufm0IDRAcwCauReWlB8qdHoDPGcsBm3z4hjwBKFqRNTsS2H21nfB60kH5d7BAycI3N5HT4KgEKe7VeyuLaOsDJ/bxPakjRkkaEB3b6UAUAmw= 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 1565276315852536.4774197449641; Thu, 8 Aug 2019 07:58:35 -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 9105430A923F; Thu, 8 Aug 2019 14:58:34 +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 655BB60DCA; Thu, 8 Aug 2019 14:58:34 +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 2CEAB180BA9E; Thu, 8 Aug 2019 14:58:34 +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 x78Ew4Lw023376 for ; Thu, 8 Aug 2019 10:58:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id EF6885C226; Thu, 8 Aug 2019 14:58:04 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 718515C205; Thu, 8 Aug 2019 14:57:57 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:06 +0400 Message-Id: <20190808145514.20789-16-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 15/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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 08 Aug 2019 14:58:35 +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 Reviewed-by: Michal Privoznik --- 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 7315fe103e..b6f7e8bacc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -32,6 +32,7 @@ #include "qemu_migration.h" #include "qemu_migration_params.h" #include "qemu_security.h" +#include "qemu_slirp.h" #include "qemu_extdevice.h" #include "qemu_blockjob.h" #include "viralloc.h" @@ -1304,6 +1305,11 @@ qemuDomainNetworkPrivateNew(void) static void qemuDomainNetworkPrivateDispose(void *obj ATTRIBUTE_UNUSED) { + qemuDomainNetworkPrivatePtr priv =3D obj; + + if (priv->slirp) { + qemuSlirpFree(priv->slirp); + } } =20 =20 @@ -2630,6 +2636,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) @@ -2731,6 +2794,9 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, if (qemuDomainObjPrivateXMLFormatBlockjobs(buf, vm) < 0) return -1; =20 + if (qemuDomainObjPrivateXMLFormatSlirp(buf, vm) < 0) + return -1; + return 0; } =20 @@ -3258,6 +3324,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, @@ -3396,6 +3502,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 7293c87d7c..84c39dfb54 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -521,7 +521,7 @@ typedef qemuDomainNetworkPrivate *qemuDomainNetworkPriv= atePtr; struct _qemuDomainNetworkPrivate { virObject parent; =20 - bool tmp_to_be_larger_than_parent; + qemuSlirpPtr slirp; }; =20 =20 --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276318; cv=none; d=zoho.com; s=zohoarc; b=N0Da9F/ajHW6v0cMoMby1S/u6aWSdxnoLIS94qOJWCIbUSPVhnbgmm7HUR9iB0oCuh+oEezWPTTLDJdVKxaTkARIweyIk/ZdTanFwCBpla/cSOl16BMGy9DIndfu+gWzDhSgsOapX2cFa6ke9tdsG/On4bV6oWYP1+tzTzYr9LU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276318; 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=KiRSa/Y7rVetmM5XBBpWRNJEccSRO5g6lbHHbEqoSS0=; b=nGI8L/MPHOmocsvERhDStgAZ3gV2bowvTgY1q5pyeMoEhrZwIDyLQuYjPrDJQpQo6G5Kp1PWD9gesxwUq25Y23u6Id6zry/sO3P+WAoh5a7LGC8I1fqJbDKR03b+laowqYpu2Phj0evXbZJarEaNa3Fqt5TiXoOJPlMxxRuD1x0= 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 1565276318968515.6824958407589; Thu, 8 Aug 2019 07:58:38 -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 D416B970DD; Thu, 8 Aug 2019 14:58:37 +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 AB7B91001B07; Thu, 8 Aug 2019 14:58:37 +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 6BC141802215; Thu, 8 Aug 2019 14:58:37 +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 x78EwGlt023394 for ; Thu, 8 Aug 2019 10:58:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id DD58260A9D; Thu, 8 Aug 2019 14:58:16 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2770D60600; Thu, 8 Aug 2019 14:58:10 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:07 +0400 Message-Id: <20190808145514.20789-17-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 16/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.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.39]); Thu, 08 Aug 2019 14:58:38 +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 Reviewed-by: Michal Privoznik --- src/qemu/qemu_domain.c | 30 ++++++++++++++++++++++++++++-- src/qemu/qemu_domain.h | 2 ++ src/qemu/qemu_driver.c | 8 ++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b6f7e8bacc..04301c0a15 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2652,6 +2652,24 @@ qemuDomainHasSlirp(virDomainObjPtr vm) } =20 =20 +static bool +qemuDomainGetSlirpHelperOk(virDomainObjPtr vm) +{ + size_t i; + + for (i =3D 0; i < vm->def->nnets; i++) { + virDomainNetDefPtr net =3D vm->def->nets[i]; + + /* if there is a builtin slirp, prevent slirp-helper */ + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_USER && + !QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp) + return false; + } + + return true; +} + + static int qemuDomainObjPrivateXMLFormatSlirp(virBufferPtr buf, virDomainObjPtr vm) @@ -14546,7 +14564,7 @@ qemuDomainSaveCookieDispose(void *obj) =20 =20 qemuDomainSaveCookiePtr -qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED) +qemuDomainSaveCookieNew(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; qemuDomainSaveCookiePtr cookie =3D NULL; @@ -14560,7 +14578,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->slirpHelper =3D qemuDomainGetSlirpHelperOk(vm); + + VIR_DEBUG("Save cookie %p, cpu=3D%p, slirpHelper=3D%d", + cookie, cookie->cpu, cookie->slirpHelper); =20 return cookie; =20 @@ -14586,6 +14607,8 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt A= TTRIBUTE_UNUSED, &cookie->cpu) < 0) goto error; =20 + cookie->slirpHelper =3D virXPathBoolean("boolean(./slirpHelper)", ctxt= ) > 0; + *obj =3D (virObjectPtr) cookie; return 0; =20 @@ -14605,6 +14628,9 @@ qemuDomainSaveCookieFormat(virBufferPtr buf, virCPUDefFormatBufFull(buf, cookie->cpu, NULL) < 0) return -1; =20 + if (cookie->slirpHelper) + virBufferAddLit(buf, "\n"); + return 0; } =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 84c39dfb54..caa2aff965 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -394,6 +394,7 @@ struct _qemuDomainObjPrivate { virHashTablePtr blockjobs; =20 virHashTablePtr dbusVMStates; + bool disableSlirp; }; =20 #define QEMU_DOMAIN_PRIVATE(vm) \ @@ -559,6 +560,7 @@ struct _qemuDomainSaveCookie { virObject parent; =20 virCPUDefPtr cpu; + bool slirpHelper; }; =20 =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ff83d1c024..4b49203738 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6971,6 +6971,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, bool start_paused, qemuDomainAsyncJob asyncJob) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; int ret =3D -1; bool restored =3D false; virObjectEventPtr event; @@ -7011,6 +7012,9 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, qemuDomainFixupCPUs(vm, &cookie->cpu) < 0) goto cleanup; =20 + if (!cookie->slirpHelper) + priv->disableSlirp =3D true; + if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL, asyncJob, "stdio", *fd, path, NULL, VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, @@ -16654,6 +16658,10 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sn= apshot, virCPUDefFree(priv->origCPU); VIR_STEAL_PTR(priv->origCPU, origCPU); } + + if (cookie && !cookie->slirpHelper) + priv->disableSlirp =3D true; + } else { /* Transitions 2, 3 */ load: --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276341; cv=none; d=zoho.com; s=zohoarc; b=Z7FbkETEwBnIUtbpMY0uAs85ceQvfJH1fuRbXOa8F5W5n5x9CHtMfxKRbGOHH3rML31MMUNcT17u08gLXK3QpJ6s4kvOtft0/PTLo+OY9zhtYfjUNokP/lafqQZOyk/HuwSwdSKR3Ugznq/vUGsqVdQ5+0Z/tvaO1qJYvx/eYgo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276341; 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=OXiPMCwfdWjW2E4MPEyBuW47Y4nl5wLIv+9iv3CO1Aw=; b=UDlyVr9CFhb/Z0R1WROqeJ7dTmJAe5d+BcUxbwhGtZk9zHUCl7CDAPQARkq8+EMugiIBdDHbO1kKMcqFgD9fgVj4+Nrq7lBty8y3SHI0bIMSBAv3v5jaUZEtbeP0lTSBR+bNFy6R4a9ftzM0t3ZaiWWQtY9nygHZiAIKByj0kd4= 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 1565276341671795.8918977765808; Thu, 8 Aug 2019 07:59:01 -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 5E30E30A5A62; Thu, 8 Aug 2019 14:59: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 39453194BB; Thu, 8 Aug 2019 14:59:00 +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 F18D183541; Thu, 8 Aug 2019 14:58:59 +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 x78EwUkj023491 for ; Thu, 8 Aug 2019 10:58:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE8305C231; Thu, 8 Aug 2019 14:58:30 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEB5E5C205; Thu, 8 Aug 2019 14:58:21 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:08 +0400 Message-Id: <20190808145514.20789-18-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 17/23] qemu-migration: prevent migration if dbus-vmstate is required 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.47]); Thu, 08 Aug 2019 14:59:00 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 7c6be201b9..86b4bfd970 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1114,6 +1114,7 @@ qemuMigrationSrcIsAllowed(virQEMUDriverPtr driver, bool remote, unsigned int flags) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; int nsnapshots; int pauseReason; size_t i; @@ -1140,7 +1141,13 @@ qemuMigrationSrcIsAllowed(virQEMUDriverPtr driver, _("cannot migrate domain with I/O error")); return false; } + } =20 + if (virHashSize(priv->dbusVMStates) > 0 && + !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("domain requires dbus-vmstate support")); + return false; } =20 /* following checks don't make sense for offline migration */ --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276345; cv=none; d=zoho.com; s=zohoarc; b=jRPjb4n9Jw6Tn9XCo+FHLQMkVK80TJskcUeMwLoW4QI0X6jGLBG8srZ8ddatuozPR0lUPp2Ex4FUH3u/BLDIC1peSaUX2yPH50F10CB86qAo/iWvn+6aHpk2g02c196kWL5QqozD7XHjtrfpVVM+C0sgMpJk1lNRV5TodgtJrdI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276345; 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=KUXwAnM3WOvOGlOQ31R9mYiZqQUGm/zKzswtiLPgV1k=; b=TTB+9j0j+sJW5Y+/ax53arnq+hF8ufYkzQuFfWX4P0WimVNq1vrKeiK6nR0ga2RIjoFOgI3d6uxYY3CyIGp/fm61Fxeir1J+388O7VU4VWT5SJGGFH+G0KifhN/TKZtvDUxenGlR4Fvl2euNjpkBCGIm9uh0p8IxMonlz0JI3wU= 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 1565276345570236.12137055409687; Thu, 8 Aug 2019 07:59: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 78278C05AA52; Thu, 8 Aug 2019 14:59:04 +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 529465C219; Thu, 8 Aug 2019 14:59:04 +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 15ABE180BAA8; Thu, 8 Aug 2019 14:59:04 +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 x78Ewbsi023535 for ; Thu, 8 Aug 2019 10:58:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 760B45C226; Thu, 8 Aug 2019 14:58:37 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id A83E95C205; Thu, 8 Aug 2019 14:58:35 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:09 +0400 Message-Id: <20190808145514.20789-19-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 08 Aug 2019 14:59:04 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 86b4bfd970..c607e9f909 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" @@ -1150,6 +1151,17 @@ qemuMigrationSrcIsAllowed(virQEMUDriverPtr driver, return false; } =20 + 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; + + if (slirp && !qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_MIGRAT= E)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("a slirp-helper cannot be migrated")); + return false; + } + } + /* following checks don't make sense for offline migration */ if (!(flags & VIR_MIGRATE_OFFLINE)) { if (qemuProcessAutoDestroyActive(driver, vm)) { --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276328; cv=none; d=zoho.com; s=zohoarc; b=mY+W7BLiTvEs4Z1HzepEqhV+JhMW2Gxoc06rOEbuf26TDk3nKym0LbiBEJa4td3hPTnDP9zb3+glVcChba6PCudvP/vvT8cauRuJU6dcvekBoPQsWRjZNFgbx8WqdyNAkGxi4AROUVL93HL/a48EWyFLr9Bm1eXOOsIpcGf9+nk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276328; 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=oV/WaqXMKV0IjC54JBNp3gwrXZClNVMk5cTkg9uqx7U=; b=esDMuyfQiPslAcDuKqlKupVLlFMr+oF/E1UICPFZCUEYnHm2KSVwoyK5TxEON53ETZXbtJcH7DocTzmdqWMgl2g475fPl1zckv8U+5PwF5VgttSEdaUDNIzR/xot+ycOB5/vGiUWrhr3/g6HlMMj5jKWF9smyAi13AQu+VzXeao= 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 1565276328732446.42145767446834; Thu, 8 Aug 2019 07:58:48 -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 8F015C05AA61; Thu, 8 Aug 2019 14:58:47 +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 6786F5DAA0; Thu, 8 Aug 2019 14:58:47 +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 20AA1180BAA1; Thu, 8 Aug 2019 14:58:47 +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 x78EwkVO023607 for ; Thu, 8 Aug 2019 10:58:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4CA396012E; Thu, 8 Aug 2019 14:58:46 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4E3C600CC; Thu, 8 Aug 2019 14:58:42 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:10 +0400 Message-Id: <20190808145514.20789-20-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 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.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.32]); Thu, 08 Aug 2019 14:58:48 +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 Reviewed-by: Michal Privoznik --- src/qemu/qemu_extdevice.c | 47 +++++++++++++++++++++++++++++++++------ src/qemu/qemu_extdevice.h | 5 +++-- src/qemu/qemu_process.c | 4 ++-- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 0aa050cb0a..179552a3ae 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 @@ -114,15 +125,26 @@ int qemuExtDevicesStart(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainLogContextPtr logCtxt, - bool incomingMigration) + qemuProcessIncomingDefPtr incoming) { + virDomainDefPtr def =3D vm->def; int ret =3D 0; + size_t i; =20 if (qemuExtDevicesInitPaths(driver, vm->def) < 0) return -1; =20 if (vm->def->tpm) - ret =3D qemuExtTPMStart(driver, vm, logCtxt, incomingMigration); + ret =3D qemuExtTPMStart(driver, vm, logCtxt, incoming !=3D NULL); + + 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, false, incoming) < 0) + return -1; + } =20 return ret; } @@ -132,11 +154,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, false); + } } =20 =20 diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h index cdd20c28ef..a526308c51 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 @@ -42,7 +43,7 @@ void qemuExtDevicesCleanupHost(virQEMUDriverPtr driver, int qemuExtDevicesStart(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainLogContextPtr logCtxt, - bool incomingMigration) + qemuProcessIncomingDefPtr incoming) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f8d740979d..d41ee0f25b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6602,7 +6602,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) @@ -6776,7 +6776,7 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuProcessGenID(vm, flags) < 0) goto cleanup; =20 - if (qemuExtDevicesStart(driver, vm, logCtxt, incoming !=3D NULL) < 0) + if (qemuExtDevicesStart(driver, vm, logCtxt, incoming) < 0) goto cleanup; =20 VIR_DEBUG("Building emulator command line"); --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276350; cv=none; d=zoho.com; s=zohoarc; b=AbhkXll5rvoOwuVrUSiINtd8cwII2ERzsI/lSAtz/CbV2f7mQq+H/Aw8h/zdmdE3dCsjVCrXkUNwbQfoAKlAr+Qv//tvLOooBXkeavLWBx6ePIf63lny2YQiwAfNA5HwhWKhqXg4pqFnc+u2sGxh4Uzga69oVxK7PLT9dSdUvk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276350; 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=BhKdthwCgGSVfMoHcGSFcDwDw4A8Lbxq0QJi8Htowls=; b=SyataWQBHTHlxTAOT9GqhhS9f1Pd14fQYiK/MhRUjIgjvTv1ClZoZFBhnS+VonAXYGF+SE0CZ+xCKzuUrszFtYBeiXDznlAAZE/0SCG/yeOr6LGqPiASrAa51rVz6e0eOc5zb0gj4pDTA9mhQUC1TsABgfvLmXs9/VgpOg177oE= 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 1565276350988592.8157104598125; Thu, 8 Aug 2019 07:59:10 -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 581A16128F; Thu, 8 Aug 2019 14:59: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 314F3100197A; Thu, 8 Aug 2019 14:59:08 +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 E5963180124D; Thu, 8 Aug 2019 14:59: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 x78EwxI1023709 for ; Thu, 8 Aug 2019 10:58:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6C24960623; Thu, 8 Aug 2019 14:58:59 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4CBC60A35; Thu, 8 Aug 2019 14:58:51 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:11 +0400 Message-Id: <20190808145514.20789-21-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 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.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.30]); Thu, 08 Aug 2019 14:59:08 +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 Reviewed-by: Michal Privoznik --- 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 4357aa2fe1..90e61a336e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -28,6 +28,7 @@ #include "qemu_alias.h" #include "qemu_security.h" #include "qemu_dbus.h" +#include "qemu_slirp.h" #include "qemu_block.h" #include "cpu/cpu.h" #include "dirname.h" @@ -4008,7 +4009,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; @@ -4079,6 +4081,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]; @@ -8634,10 +8642,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, @@ -8646,6 +8654,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; @@ -8656,9 +8665,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 @@ -8884,6 +8895,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) @@ -8908,7 +8929,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 @@ -8976,10 +8998,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, @@ -8990,6 +9012,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; @@ -9005,7 +9028,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) @@ -10815,7 +10838,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildFilesystemCommandLine(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 3a957c52fc..6faa6f2b18 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 028921fb47..43c3f0755b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1135,6 +1135,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; @@ -1373,7 +1374,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.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276358; cv=none; d=zoho.com; s=zohoarc; b=kpsec/Zy+Zp3PyYDHIM3NcOwODXPBwDxhi6b3CstZWdNwZ03SJyLws39g9UOU64PD54qllfTUgpW8rba/JCt4VaepdAdy+bD0nyCW/W9GOcDQT3Mx5bB3byrP2RBSeU2JzMASfjhKqMFmEDyFbkvKE6GOa9ZxgfxVOQo35xL3Us= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276358; 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=YWVvsZHvUFh5cjvNb49b4vhxg4NHWJDcWYRJSruDrx8=; b=lCE9Xcq3hDGSp6oUbZpY4zbfF0ywqAtBkef5HvzUmLWUA8kJxjmTyKvosE1Cs9ZNI+yg1Za7eVYXfuPc/X2OTgZP7ucQjjNuIRJEDCBffrKJeAREejf49ymQJY7DKOiFrj3OApAFCOEC3mjdexRTcPlFwMIPrV8+aPgkDLGuGKI= 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 1565276358358239.6443767898395; Thu, 8 Aug 2019 07:59:18 -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 1D7DD970F6; Thu, 8 Aug 2019 14:59: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 E88575B6A5; Thu, 8 Aug 2019 14:59: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 A456983554; Thu, 8 Aug 2019 14:59:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78ExFPH023830 for ; Thu, 8 Aug 2019 10:59:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 423B81001959; Thu, 8 Aug 2019 14:59:15 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id A659F1001B07; Thu, 8 Aug 2019 14:59:03 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:12 +0400 Message-Id: <20190808145514.20789-22-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 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.39]); Thu, 08 Aug 2019 14:59:17 +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 disableSlirp (in particular when resuming a VM that didn't start with slirp-helper before). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- src/qemu/qemu_interface.c | 27 +++++++++++++++++++++++++++ src/qemu/qemu_interface.h | 4 ++++ src/qemu/qemu_process.c | 16 +++++++++++++--- 3 files changed, 44 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 d41ee0f25b..d1d73d55c7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5688,8 +5688,11 @@ qemuProcessInit(virQEMUDriverPtr driver, * qemuProcessNetworkPrepareDevices */ static int -qemuProcessNetworkPrepareDevices(virDomainDefPtr def) +qemuProcessNetworkPrepareDevices(virQEMUDriverPtr driver, + virDomainObjPtr vm) { + virDomainDefPtr def =3D vm->def; + qemuDomainObjPrivatePtr priv =3D vm->privateData; int ret =3D -1; size_t i; virConnectPtr conn =3D NULL; @@ -5734,7 +5737,14 @@ qemuProcessNetworkPrepareDevices(virDomainDefPtr def) } if (virDomainHostdevInsert(def, hostdev) < 0) goto cleanup; - } + } else if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_USER && + !priv->disableSlirp && + 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: @@ -6535,7 +6545,7 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, * will need to be setup. */ VIR_DEBUG("Preparing network devices"); - if (qemuProcessNetworkPrepareDevices(vm->def) < 0) + if (qemuProcessNetworkPrepareDevices(driver, vm) < 0) goto cleanup; =20 /* Must be run before security labelling */ --=20 2.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276369; cv=none; d=zoho.com; s=zohoarc; b=SQtQ0Wv5sixPuCl4bbvnyP/vvmO2u33VSUlYskEo8RY3ssjmixzKVbyZQlu7WC8XMW/HE5fXWv9cPqu3V0fZZpa4a1Wn/+EhvKkprUZSnXa4xO4k5ruElIcVdgS3CJoI0gtHqIzqsqzAGN2yqhtQSt39tsAAoeTkv5D04HyfuIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276369; 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=xEE0ZQY/iAL7NymsXPti9GG7TyJPIOA2nq9r9mcyyzk=; b=fhf29k09PgGPl8DH6pvH9FlIZ+tcWHt9r8zx1HLC5zhE64A8DE3I8MAIEo/U3fnYaO4A6r/SscJZqOl43OMl0l1AxU1XpZfAm83p3v8ympRE9tM8IRTXw3ACzg0l5jTnD9Kq9aaDxxWiQgaUyNtuXxgeT0FmTPZwSoe3wHkIx9s= 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 1565276369395347.3726321441726; Thu, 8 Aug 2019 07:59:29 -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 D858FCCFE8; Thu, 8 Aug 2019 14:59:25 +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 B25C45B6A5; Thu, 8 Aug 2019 14:59:25 +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 710A883545; Thu, 8 Aug 2019 14:59:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x78ExOlj023904 for ; Thu, 8 Aug 2019 10:59:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2BB97100194E; Thu, 8 Aug 2019 14:59:24 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 811DD1001B07; Thu, 8 Aug 2019 14:59:19 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:13 +0400 Message-Id: <20190808145514.20789-23-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 08 Aug 2019 14:59:26 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- src/qemu/qemu_hotplug.c | 33 ++++++++++++++++++++++++++++++--- src/qemu/qemu_monitor.c | 13 ++++++++++--- src/qemu/qemu_monitor.h | 3 ++- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 43c3f0755b..fcbf7a8aa9 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1136,6 +1136,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; @@ -1315,7 +1316,26 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, break; =20 case VIR_DOMAIN_NET_TYPE_USER: - /* No preparation needed. */ + if (!priv->disableSlirp && + 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, true, 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: @@ -1391,7 +1411,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; @@ -1506,6 +1527,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, VIR_FREE(charDevAlias); virObjectUnref(conn); virDomainCCWAddressSetFree(ccwaddrs); + VIR_FORCE_CLOSE(slirpfd); =20 return ret; =20 @@ -1516,6 +1538,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, true); if (charDevPlugged && qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0) VIR_WARN("Failed to remove associated chardev %s", charDevAlia= s); @@ -2201,7 +2225,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) @@ -4674,6 +4698,9 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, if (qemuDomainObjExitMonitor(driver, vm) < 0) goto cleanup; =20 + if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp) + qemuSlirpStop(QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp, vm, driver,= net, true); + virDomainAuditNet(vm, net, NULL, "detach", true); =20 for (i =3D 0; i < vm->def->nnets; i++) { diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index a880da3ab6..84af24958a 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2844,15 +2844,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 @@ -2865,6 +2867,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 88c9702530..c675865e3f 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -880,7 +880,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.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Mar 28 08:48:10 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=1565276382; cv=none; d=zoho.com; s=zohoarc; b=D+trlmLy38RsjyUuYc9L92EnOJcV/qU39uGiZeyOjzCbyP4ib4NTYzjJ/7EvTaUziSoXELEE+Qzl2qnDVZoT/2xSsDCfT/KdJf9BLN9zgMeyYEHtBObh5ug/RQO4KrvqokJYs7L2ymI17yXhs4wYu3Cd7HNaObjXxQkcW7LmmMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565276382; 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=X/7mN6/kw/DmF1eTN+ItM7ru0mIATdA+HI7/0Fb5jK0=; b=ZOEiiFD/ZaDTQ6hGAvLUQ0plTXgzIbAciAVZH0LTPgHljX542OqCajk/tjAUx4lswdSmofPRgu4JORvJ5bOGKNQmbUsmGXg8XUFPOFVxzlP1hTkUDwrV95opB+ldTEcpk2w+cmmyKW1TsdoLmjjsjiwyI3uqNJ3VQBeddRTe7YQ= 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 1565276382226683.7730323588977; Thu, 8 Aug 2019 07:59:42 -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 966313098428; Thu, 8 Aug 2019 14:59: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 5BC85600F8; Thu, 8 Aug 2019 14:59: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 16ED61800B74; Thu, 8 Aug 2019 14:59:38 +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 x78ExbUe023945 for ; Thu, 8 Aug 2019 10:59:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 75FA961F24; Thu, 8 Aug 2019 14:59:37 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24AD41EC; Thu, 8 Aug 2019 14:59:29 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Thu, 8 Aug 2019 18:55:14 +0400 Message-Id: <20190808145514.20789-24-marcandre.lureau@redhat.com> In-Reply-To: <20190808145514.20789-1-marcandre.lureau@redhat.com> References: <20190808145514.20789-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH v2 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 08 Aug 2019 14:59:39 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michal Privoznik --- .../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 c166fd18d6..1d1c3292ec 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.23.0.rc1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list