From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 0B9F45A026B for ; Wed, 22 Feb 2023 01:36:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677026164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CvKTd5NVOmXBBr0xjMtsQz64KBydcjNfzAHLFo9R+Ws=; b=Gz6IqdZKP8Zu5cfzlbPFY7wd9pru9YTzk9a6nNIO9KUXfy0GRfFIVpM9jG03kJabDaL6yE D3PSp5h7TU/CG9xRfI1BgdlY9PYboI3trcLkV8W7XTuj9IQU1xGpKi1hDU5Jbt0KuAxd5W H/gcbxowa7EbbqaFUycQ4nkylI/NUIk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-574-crPjNVCaNQGr2MT6kRP1Qw-1; Tue, 21 Feb 2023 19:36:00 -0500 X-MC-Unique: crPjNVCaNQGr2MT6kRP1Qw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D997A800B23 for ; Wed, 22 Feb 2023 00:35:59 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.2.16.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE3C92026D4B; Wed, 22 Feb 2023 00:35:59 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] qemu: add reconnect=5 to passt qemu commandline options when available Date: Tue, 21 Feb 2023 19:35:58 -0500 Message-Id: <20230222003559.62442-3-laine@redhat.com> In-Reply-To: <20230222003559.62442-1-laine@redhat.com> References: <20230222003559.62442-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: KAUY474SUITDBXTFHU2MP2QJKI7WA6HI X-Message-ID-Hash: KAUY474SUITDBXTFHU2MP2QJKI7WA6HI X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: QEMU's "reconnect" option of "-netdev stream" tells QEMU to periodically (period is given in seconds as an argument to the option) attempt to reconnect to the same passt socket to which it had originally connected to. This is useful in cases where the passt process terminates, and libvirtd starts a new passt process in its place (which doesn't happen yet, but will happen automatically after an upcoming patch in this series). Since there is no real hueristic for determining the "best" value of the reconnect interval, rather than clutter up config with a knob that nobody knows how to properly twiddle, we just set the reconnect timer to 5 seconds. "-netdev stream" first appeared in QEMU 7.2.0, but the reconnect option won't be available until QEMU 8.0.0, so we need to check QEMU capabilities just in case someone is using QEMU 7.2.0 (and thus can support passt backend, but not reconnect) Signed-off-by: Laine Stump --- src/qemu/qemu_passt.c | 11 ++++++ .../net-user-passt.x86_64-7.2.0.args | 37 +++++++++++++++++++ .../net-user-passt.x86_64-latest.args | 2 +- tests/qemuxml2argvtest.c | 1 + 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/net-user-passt.x86_64-7.2.0.args diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index 1217a6a087..55199c9d36 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -83,6 +83,8 @@ qemuPasstAddNetProps(virDomainObj *vm, { g_autofree char *passtSocketName = qemuPasstCreateSocketPath(vm, net); g_autoptr(virJSONValue) addrprops = NULL; + qemuDomainObjPrivate *priv = vm->privateData; + virQEMUCaps *qemuCaps = priv->qemuCaps; if (virJSONValueObjectAdd(&addrprops, "s:type", "unix", @@ -98,6 +100,15 @@ qemuPasstAddNetProps(virDomainObj *vm, NULL) < 0) { return -1; } + + /* a narrow range of QEMU releases support -netdev stream, but + * don't support its "reconnect" option + */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV_STREAM_RECONNECT) && + virJSONValueObjectAdd(netprops, "u:reconnect", 5, NULL) < 0) { + return -1; + } + return 0; } diff --git a/tests/qemuxml2argvdata/net-user-passt.x86_64-7.2.0.args b/tests/qemuxml2argvdata/net-user-passt.x86_64-7.2.0.args new file mode 100644 index 0000000000..037dabb87d --- /dev/null +++ b/tests/qemuxml2argvdata/net-user-passt.x86_64-7.2.0.args @@ -0,0 +1,37 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc-i440fx-7.2,usb=off,dump-guest-core=off,memory-backend=pc.ram \ +-accel tcg \ +-cpu qemu64 \ +-m 214 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-format","id":"ide0-0-0","bootindex":1}' \ +-netdev '{"type":"stream","addr":{"type":"unix","path":"/bad-test-used-env-xdg-runtime-dir/libvirt/qemu/run/passt/-1-QEMUGuest1-net0.socket"},"server":false,"id":"hostnet0"}' \ +-device '{"driver":"rtl8139","netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:55","bus":"pci.0","addr":"0x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/net-user-passt.x86_64-latest.args b/tests/qemuxml2argvdata/net-user-passt.x86_64-latest.args index 48e3e8ca8b..f84bec2ec1 100644 --- a/tests/qemuxml2argvdata/net-user-passt.x86_64-latest.args +++ b/tests/qemuxml2argvdata/net-user-passt.x86_64-latest.args @@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ -device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-format","id":"ide0-0-0","bootindex":1}' \ --netdev '{"type":"stream","addr":{"type":"unix","path":"/bad-test-used-env-xdg-runtime-dir/libvirt/qemu/run/passt/-1-QEMUGuest1-net0.socket"},"server":false,"id":"hostnet0"}' \ +-netdev '{"type":"stream","addr":{"type":"unix","path":"/bad-test-used-env-xdg-runtime-dir/libvirt/qemu/run/passt/-1-QEMUGuest1-net0.socket"},"server":false,"reconnect":5,"id":"hostnet0"}' \ -device '{"driver":"rtl8139","netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:55","bus":"pci.0","addr":"0x2"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index b897814a5d..5a33c336c8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1471,6 +1471,7 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST_FULL("net-user", "x86_64", ARG_FLAGS, FLAG_SLIRP_HELPER); DO_TEST_NOCAPS("net-user-addr"); DO_TEST_CAPS_LATEST("net-user-passt"); + DO_TEST_CAPS_VER("net-user-passt", "7.2.0"); DO_TEST_NOCAPS("net-virtio"); DO_TEST_NOCAPS("net-virtio-device"); DO_TEST_NOCAPS("net-virtio-disable-offloads"); -- 2.39.2